View topic - spawn(),exec(): child pid

Page 1 of 1

spawn(),exec(): child pid

PostPosted: Wed Apr 07, 2010 7:45 am
by ninja123
Hi All,


I want to create a child process that would start 'solitaire'(or any other game).
I want the pid of this game process.

How do I use spawnvp() in this context as spawn*() returns the pid of the process??

I tried the following:
Code: Select all
char *const parmList[] ={"sh", "-c", "/usr/photon/bin/solitaire", NULL};
............
pid_t  pid = 0;
pid = spawnvp(P_NOWAIT, "sh",parmList);


But the problem here is the return of 'pid' is the pid of the /bin/sh and not solitaire.

How do I change this?

Or is there any other way??

Thanks in advance

RE: spawn(),exec(): child pid

PostPosted: Wed Apr 07, 2010 10:53 am
by mario
then why do you start sh and not solitaire directly?