Problem with fork inside a thread and system()
- From: CMorgan <uestebanez@xxxxxxxxx>
- Date: Fri, 28 Dec 2007 07:27:19 -0800 (PST)
Hi everybody,
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.....
}
}
in var/log/messages I can read:
daemon.notice pppd[2145]: pppd 2.4.3 started by root, uid 0 <----
this is O.K.
daemon.err pppd[2145]: Connect script failed <--- I can't believe
it!!!
On the other hand I made a simple program with a main and a simple
fork and system call and this is right and works fine!!!! I can't
believe it!!!!
Is there any difference between call system inside a child created
from a thread and a child created from a single main (wich is also a
thread).
Regards,
Unai.
.
- Follow-Ups:
- Re: Problem with fork inside a thread and system()
- From: Rainer Weikusat
- Re: Problem with fork inside a thread and system()
- Prev by Date: Re: what are the respective tasks of windows manager, desktop, and the gui app
- Next by Date: Re: Problem with fork inside a thread and system()
- Previous by thread: what are the respective tasks of windows manager, desktop, and the gui app
- Next by thread: Re: Problem with fork inside a thread and system()
- Index(es):
Relevant Pages
|