Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

difference between exec, system, fork, pipe, syscall and eval

by abhi.nitk2003 (Initiate)
on Mar 19, 2010 at 14:49 UTC ( #829635=perlquestion: print w/ replies, xml ) Need Help??
abhi.nitk2003 has asked for the wisdom of the Perl Monks concerning the following question:

I want to know the difference between exec, system, fork, pipe, syscall and eval as I know these all are system built in function to creating a process.Please help me with a small piece of code examples.

Comment on difference between exec, system, fork, pipe, syscall and eval
Re: difference between exec, system, fork, pipe, syscall and eval
by ikegami (Pope) on Mar 19, 2010 at 15:00 UTC
Re: difference between exec, system, fork, pipe, syscall and eval
by toolic (Chancellor) on Mar 19, 2010 at 15:00 UTC
Re: difference between exec, system, fork, pipe, syscall and eval
by kennethk (Monsignor) on Mar 19, 2010 at 15:03 UTC
    The differences between these various elements are detailed in exec, system, fork, pipe, syscall and eval. You've also forgotten backticks, which is the method I need most often. Please note that eval does not invoke the operating system at all, rather invokes the Perl interpreter on the string you pass it. What are you trying to do?
Re: difference between exec, system, fork, pipe, syscall and eval
by JavaFan (Canon) on Mar 19, 2010 at 15:44 UTC
    • exec replaces the current process with another one.
    • system runs another program, wait for its completion.
    • fork copies the current process; both the original and the copy continue from the same point.
    • pipe sets up a pipe between two handles.
    • syscall makes a low-level system call.
    • eval executes (the string form will first compile) a piece of Perl code.
    I know these all are system built in function to creating a process.
    Uhm, you know wrongly.
Re: difference between exec, system, fork, pipe, syscall and eval
by ssandv (Hermit) on Mar 19, 2010 at 23:01 UTC

    You also forgot open. And this sounds like homework. It might be helpful if you clarified why this isn't something you can answer yourself with perldoc.

      - exec is used to execute the given process by replacing the current process.
      - If the given process get executed successfully then exec will not return the value.
      - exec returns the value in case of failure only.

      - System is also doing the same thing as exec but system returns value in both success and failure cases.
      - And parent process waits for the child process to complete.
      - System() runs the command through a shell,while exec() runs the command directly.

      - fork is used to create a new process(child process).
      - And it is returning the PID of child to parent and zero to child if the fork is successful.
      - The difference between the fork and exec is exec replaces the current process but fork doesn't.

      - pipe is used for communicating between two processes.
      - We can use both named and nameless pipes.
      - It returns open a pair of pipes.
      - In one end we can write.
      - And in another end we can read the content.

      - syscall is used to call the system call which is specified as a first argument.
      - Remaining elements are the arguments to the system call.

      For more details visit the following link also. Perl IPC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://829635]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-09-18 15:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (116 votes), past polls