Re: Launch and kill external executable
- From: Bjarni Juliusson <bjarni@xxxxxxxxxxxx>
- Date: Fri, 14 Nov 2008 18:28:55 +0100
Guillaume Dargaud wrote:
Hello all,
This is pretty simple but I'm very new to Posix/Linux specific calls.
I want to launch an external script or executable from a C prog, and later on kill it from that same prog.
I've seen
int kill(pid_t pid, int sig);
which does the 2nd part of the job, but none of the ANSI C functions (system(), exec(), execl()...) return the pid of the launched process. Is there a more powerful Posix/Linux equivalent ?
I guess I could have a wrapper script with ps|grep to get the pid and pass it back to the program, but I'm sure there's a better way to do that.
The system call that creates a new process is fork(). The exec family of functions simply replaces the program running in the current process. Thus, to start an external executable, you fork and then exec in the child.
Welcome to Unix! :-)
Bjarni
--
INFORMATION WANTS TO BE FREE
.
- References:
- Launch and kill external executable
- From: Guillaume Dargaud
- Launch and kill external executable
- Prev by Date: Launch and kill external executable
- Next by Date: Re: Launch and kill external executable
- Previous by thread: Launch and kill external executable
- Next by thread: Re: Launch and kill external executable
- Index(es):