Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

need help on fork() and exec()

Good day

Can anybody assist me on my C project?I gotta write a C program to create a new process and within that new process execute a given function,and it focuses on the usage of system calls fork() and exec().

The user should be able to input and specify a pathname of a file to be executed and the required arguments or a string indicating the end of the run.The program should fork a child to execute the required program.

Really need the answer A.S.A.P...thanks a lot!

lutfi_k


Comments

  • bilderbikkelbilderbikkel Member Posts: 754
    Please don't crosspost.
    bilderbikkel
  • unixfreakunixfreak Member Posts: 9
    my dear freind,
    google/use richard steven's advanced programming in Unix environment.
    thats wgat i do normally, if cant find then reply i will give you the
    link.
    well!!
    fork()
    it divides the process in two or more parts after each its calling into: parent process and child process, where child process is pid==0

    so
    If(int Childpid==0)
    {
    exec(what the child has to do);
    }
    else
    {
    ask parent to do what you want
    }also make sure you dont create a situation where parent is completed before child....rest please read the suggested link
    http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html
    hope it will help, if not then please ask
  • lutfi_klutfi_k Member Posts: 3
    thanks a lot for the reply!
    will try and solve the problem.

Sign In or Register to comment.