subroutines in c
what do you use to call another program in c and then come beck to the one that called it?
System is close but has error handling problems
exec is close but does not come back to the calling program
Thanks
Dave
Web Development
what do you use to call another program in c and then come beck to the one that called it?
System is close but has error handling problems
exec is close but does not come back to the calling program
Thanks
Dave
by alnikolov
You should use _spawn. It has number of versions depending on what is the environment and command line paramenters that the child process receives after the call. You can execute _spawn in 4 different modes: overlay, wait, nowait and detach.
In overlay mode it is the same as exec.
In wait mode it waits untill the child process finishes and the return value is the exit status of the new process. In the oter modes the return value is the hendel of the child process.
A return value of –1 indicates an error (the new process is not started). In this case, errno is set to one of the following values:
E2BIG - Argument list exceeds 1024 bytes
EINVAL - mode argument is invalid
ENOENT - File or path is not found
ENOEXEC - Specified file is not executable or has invalid executable-file format
ENOMEM - Not enough memory is available to execute new process
This discussion is closed to new replies.
Sort by Trending