[Mplayer-cvslog] CVS: main mplayer.c,1.786,1.787

D Richard Felker III dalias at aerifal.cx
Fri Sep 17 20:14:19 CEST 2004


On Fri, Sep 17, 2004 at 12:14:23AM +0200, Torinthiel wrote:
> On Thu, Sep 16, 2004 at 05:29:05PM -0400, D Richard Felker III wrote:
> > > > will the children get reaped when they exit, or will zombie processes
> > > > hang around forever??
> > > 
> > > I'm not sure what you mean. The children will run as if you started them from 
> > > another shell. They are completely independant from MPlayer after the start. 
> > 
> > no they are not! any process that spawns child processes has to wait()
> > for them in the sigchld handler. otherwise they will become zombies
> > and keep using a pid forever until the parent process dies. mplayer
> > may already do this, but you need to check...
> 
> WTF? Yes they are. Every process that looses parent is adopted by init.
> And init then takes care of freeing pid.
> Oh, maybe if it's already dead by the time MPlayer finishes than
> something may go wrong. Testing...
> kraken:~/mplayer/mplayer-pl/DOCS/pl$ ps -l
> F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
> 0 S   500  4299  4297  0  75   0 -   693 wait4  pts/2    00:00:00 bash
> 0 S   500  4333  4299  0  68   0 -   449 wait4  pts/2    00:00:00 groff
> 0 S   500  4335  4333  0  69   0 -   492 pipe_w pts/2    00:00:00 pre-grohtml
> 0 S   500  4336  4333  0  69   0 -   460 pipe_w pts/2    00:00:00 post-grohtml
> 0 Z   500  4337  4335  0  68   0 -     0 exit   pts/2    00:00:00 groff <defunct>
> 0 R   500  4396  4299  0  77   0 -   751 -      pts/2    00:00:00 ps
> [ so second groff is dead, pre-html does not handle it]
> kraken:~/mplayer/mplayer-pl/DOCS/pl$ kill -9 4335
> kraken:~/mplayer/mplayer-pl/DOCS/pl$ groff: pre-grohtml: Killed
> ps -l
> F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
> 0 S   500  4299  4297  0  74   0 -   693 wait4  pts/2    00:00:00 bash
> 0 R   500  4746  4299  0  78   0 -   751 -      pts/2    00:00:00 ps
> Well, it looks like it got handled. I don't see anything wrong here.
> Oh, yes. 'until the parent process dies'. Yes, that's correct. But if
> you wait too often then it's loosing time on waiting for child
> processes. And if you don't everything gets handled on exit. What's the
> problem?

it's incorrect and will use up all pid's if mplayer is running too
long!!! think of -loop. you always need to reap children, but it's
very easy -- you handle sigchld! don't wait() again and again in your
main loop, that would waste lots of time.

rich




More information about the MPlayer-cvslog mailing list