Re: Problem with fork inside a thread and system()
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Fri, 28 Dec 2007 16:36:38 +0100
CMorgan <uestebanez@xxxxxxxxx> writes:
I am experiencing an annoying problem with fork() and system()
In my program I need to launch the "pppd" from a thread, so, I create
a new process with fork and then in the child process I launch with
system the pppd to connect an embedded system to internet.
The problem is that pppd fails.
Here is my example code:
int my_thread(...)
{
pid=fork();
if (pid==EAGAIN || pid==ENOMEM)
{
abort();
}
switch(pid)
{
case 0: // child
{
system ("/usr/sbin/pppd call gprs");
printf("Error execv:%s",strerror(errno));
exit(0);
}
break;
case -1:
abort();
break;
default: // father
father stuff.....
}
}
Independently (but maybe related to) of your problem: system already
forks & waits for you, meaning there is no reason to call system from
a forked processes, except insofar this means the process calling
system isn't halted until the command has exited. If you don't want
the latter, don't use system,
.
- Follow-Ups:
- Re: Problem with fork inside a thread and system()
- From: CMorgan
- Re: Problem with fork inside a thread and system()
- From: CMorgan
- Re: Problem with fork inside a thread and system()
- References:
- Problem with fork inside a thread and system()
- From: CMorgan
- Problem with fork inside a thread and system()
- Prev by Date: Problem with fork inside a thread and system()
- Next by Date: Re: Problem with fork inside a thread and system()
- Previous by thread: Problem with fork inside a thread and system()
- Next by thread: Re: Problem with fork inside a thread and system()
- Index(es):
Relevant Pages
|