Unix Programming - fork to create ppp link !!!

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2006 > fork to create ppp link !!!





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author fork to create ppp link !!!
sumit1680@rediffmail.com

2006-11-21, 7:24 am

Hi ,

I am sorry if the topic is off this group but i will post anyway.

I am stuck with a issue here .
what i have been trying is to start a PPP link between a phone and host
(n/w) using PPPD daemon in linux using my code.

the psuedo code being something like

pid = fork();

if (pid==0) //child
execlp("/usr/sbin/pppd","115200",file,"<a unique file >",NULL);

else
record_pid in parent;


The unique file has params( is created at run time ):
<device > ( for ex /dev/ttymzx0 for UART 1)
crtscts
nodetach
noauth
defaultroute

Now the issue :
This piece of code is run on a Mobilinux platform with PPPD .ko
inserted in kernel at run time.

(let me be specific , the intention here is to bring up a data path
between phone and network using AT or else !)

but this call does not result in pppd to start else i can see a zombie
process cretaed whcih of course is handled by my signal handlers.

Now if i write a small C program to do the exact above only ( devoid of
all the else i did in my module ) and use the cross compiler to get the
executble for ARM and run it independently on target then this does
seem to bring up the pppd daemon and process does not dies as in my
module.The data path is actully up !!!! the PID of PPPD cnfnms this .

what am i doing wrong?Pls comment .....
thanks for the answers!!!

Rainer Temme

2006-11-21, 7:24 am

sumit1680@rediffmail.com wrote:

> pid = fork();
>
> if (pid==0) //child
> execlp("/usr/sbin/pppd","115200",file,"<a unique file >",NULL);
> else
> record_pid in parent;



> The unique file has params( is created at run time ):
> <device > ( for ex /dev/ttymzx0 for UART 1)
> crtscts
> nodetach
> noauth
> defaultroute


> but this call does not result in pppd to start else i can see a zombie
> process cretaed whcih of course is handled by my signal handlers.


If you don't see the pppd process in the process list, and instead see
a zombie, it's an indication that the pppd you invoced has been
unhappy (with its parameters for instance) and has already terminated.

You might check, if you can switch debugging on (in the pppd) to get
more information.

Just a thought ... is it possible, that you pass more than one
parameters in the 'file' variable, or in the string "<a unique file >" ?

Should that be the case, split it into separate params...
$ program a b c
is something different than
$ program "a b c"
pppd will likely expect all parameters as distinct arguments in
his argument list.

Rainer
Torgny Lyon

2006-11-21, 1:19 pm

sumit1680@rediffmail.com wrote:
> execlp("/usr/sbin/pppd","115200",file,"<a unique file >",NULL);


The second parameter should be the name of the program, so
execlp("pppd", "pppd", "115200" ....
should work better for ya.

--
Torgny Lyon
James Carlson

2006-11-22, 7:27 am

sumit1680@rediffmail.com writes:
> execlp("/usr/sbin/pppd","115200",file,"<a unique file >",NULL);


That looks mangled. I don't think you want to set arg0 to "115200."
I would do this:

execlp("/usr/sbin/pppd", "pppd" "115200", "file", "<a unique file >", NULL);

(I might also consider execl instead of execlp unless there's some
reason to believe that /usr/sbin/pppd is a shell script.)

> crtscts
> nodetach
> noauth
> defaultroute


That's a slightly odd set of options. This looks like a dial-out
connection, but there's no "connect" parameter or chat script here.
There's also no "user" option to configure authentication.

If you're doing the dialing within your application and then launching
pppd as a subprocess, then I think you're going about this the wrong
way. You should *not* be giving pppd the name of a tty device or the
speed to use or the crtscts option. Instead, make sure that the tty
you've configured and dialed is open on standard input (use
"dup2(tty_fd, 0);") in the child that execs pppd. Pppd will detect
this and use it.

> but this call does not result in pppd to start else i can see a zombie
> process cretaed whcih of course is handled by my signal handlers.


Do your signal handlers do a waitpid()? If not, why not? If so, then
what status value is returned? The pppd man page documents a set of
exit values that tell you exactly what went wrong.

You should also add "debug" to the options and make sure that the
daemon.debug syslog facility is redirected to a file in
/etc/syslog.conf. It's possible that your problem is in PPP
configuration rather than in the C code.

--
James Carlson, KISS Network <james.d.carlson@sun.com>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com