How to get a list of all child pid's of the current process?

How to get a list of all child pid's of the current process?

Post by Kenny Cheun » Sat, 14 Jun 2003 10:43:36



Hi there,

Is there a call that will allow me to get a list of child pid's that belongs
to the current process? In my program, I am using some third party app API's
to spawn their program engine. Their APIs only return some internal engine
ID instead of the pid of the process created. What I would like to do is to
get a list of pid's of my app's children processes so that in some emergency
cases, I can call kill(cpid, SIGKILL) on them.

Any ideas?

Thanks in advance.

Kenny

--
Kenny K. Cheung
Aeronautics Task Manager/
Principal Software Engineer
Raytheon ITSS
(650) 604-5449

 
 
 

How to get a list of all child pid's of the current process?

Post by Derk Gwe » Sat, 14 Jun 2003 11:19:16


# Hi there,
#
# Is there a call that will allow me to get a list of child pid's that belongs
# to the current process? In my program, I am using some third party app API's
# to spawn their program engine. Their APIs only return some internal engine
# ID instead of the pid of the process created. What I would like to do is to
# get a list of pid's of my app's children processes so that in some emergency
# cases, I can call kill(cpid, SIGKILL) on them.

There is no single method for all possible unices. The closest you can get
is to scan the output of ps. But even ps has different parameters on different
unices. On SVID systems I think $(ps -ef | awk '{print $1,$2}') is widely
available, while on BSD I think it might be $(ps -j | awk '{print $2,$3}').

--
Derk Gwen http://derkgwen.250free.com/html/index.html
If your job was as meaningless as theirs, wouldn't you go crazy too?

 
 
 

How to get a list of all child pid's of the current process?

Post by Frank Cusac » Sat, 14 Jun 2003 12:24:13



Quote:> Hi there,

> Is there a call that will allow me to get a list of child pid's that
> belongs to the current process?

I don't think so.

Quote:> In my program, I am using some third party app API's to spawn their
> program engine. Their APIs only return some internal engine ID
> instead of the pid of the process created. What I would like to do
> is to get a list of pid's of my app's children processes so that in
> some emergency cases, I can call kill(cpid, SIGKILL) on them.

You could do something like block SIGTERM and then do kill(0, SIGTERM)
if you want to get all of them, unless the children go off and form
their own process group.

/fc

 
 
 

How to get a list of all child pid's of the current process?

Post by Kenny Cheun » Sun, 15 Jun 2003 04:00:28


Thanks for the suggestion. Doing a kill on the group works!

Kenny



> > Hi there,

> > Is there a call that will allow me to get a list of child pid's that
> > belongs to the current process?

> I don't think so.

> > In my program, I am using some third party app API's to spawn their
> > program engine. Their APIs only return some internal engine ID
> > instead of the pid of the process created. What I would like to do
> > is to get a list of pid's of my app's children processes so that in
> > some emergency cases, I can call kill(cpid, SIGKILL) on them.

> You could do something like block SIGTERM and then do kill(0, SIGTERM)
> if you want to get all of them, unless the children go off and form
> their own process group.

> /fc

 
 
 

1. Getting children's PID with parent's pid?

Hi all,

     Is there a way to get children's pid, given the parent's pid in
C++, RedHat 6.2?? I'm looking for something that is similar to
getppid, getpid... instead of parsing anything from /proc or ps.

     Note that I'm not the one who fork the children...

Thanks!

- Mag

2. Detecting another instance of a script

3. Getting a child and child's child process-id

4. RXVT: background image?

5. basic authorization (.htaccess) = weak security??

6. child process' killer's pid

7. Patch #101277-02 ?

8. How to find children PID's given parent PID?

9. getting process's pid in a script

10. Parent process getting child's environment?

11. Getting error "couldn't spawn child process: "

12. smail failed to reap child process: No child processes