[CentOS] program calls system() gettind PID - slightly off topic
Garrick Staples
garrick at usc.edu
Fri Oct 19 00:34:52 UTC 2007
On Thu, Oct 18, 2007 at 08:07:46PM -0400, Jerry Geis alleged:
> I have a C program on centos. When I call system("some_program &");
> how do I get the PID of the some_program?
>
> I cant just list processes as there might be more than one some_program
> active.
> I need to know the one that I just started.
You don't. At least not by using system().
Use fork() and exec() and you will have the child pid.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20071018/05ff4236/attachment.sig>
More information about the CentOS
mailing list