
- Forum
- Programming Talk
- C and C++
- Difference in Commands
Difference in Commands
This is a discussion on Difference in Commands within the C and C++ forums, part of the Programming Talk category; I want to try out shell commands with C programming. I am confused with the usage of some of the ...
-
Difference in Commands
I want to try out shell commands with C programming. I am confused with the usage of some of the commands namely popen(), pclose() spawn and exec. Can anyone tell me the difference in usage between these commands? In what scenarios would a user use the above commands?
-
popen and pclose commands are used by users for reading the standard output or also for writing to the standard input of the command they invoke in a very efficient and easier manner. The commands system() is used for carrying out the execution of commands given by user in the command prompt. spawn and exec are used for defining and controlling level of access of users at various levels as per needs of user.
-
02-22-2012, 05:30 AM #3
- Join Date
- Feb 2012
- Answers
- 66
The popen() function opens a process by creating a pipe. Since a pipe is by definition unidirectional, the type argument may specify only reading or writing, not both.
The pclose function closes the standard I/O stream, waits for the command to terminate, and returns the termination status.If the shell cannot be executed, the termination status returned by pclose is as if the shell had executed exit.
The Exec command is used to start execution of another program and end the execution of the existing program.
The Spawn command is used to start execution of another program without terminating the existing program.
-
Sponsored Ads

Reply With Quote





