Discussion:
[MPlayer-users] Slave Command "run" doesn't reap forks
Amir Hassan
2015-04-08 17:42:52 UTC
Permalink
I'm using the run command to periodically print the time_pos and length.

<code>
pausing_keep run "echo TIMEPOS: ${time_pos}/${length} > /dev/stdout"
</code>

but every call creates a zombie because the fork created for the shell is
not waited for.
i patched command.c to wait for the fork and it works. should i create a
patch or is for some reason this behavior intended?

I am using MPlayer SVN-r37386-snapshot-4.9.2.

greets,
amir
Reimar Döffinger
2015-04-14 06:54:50 UTC
Permalink
Post by Amir Hassan
I'm using the run command to periodically print the time_pos and length.
<code>
pausing_keep run "echo TIMEPOS: ${time_pos}/${length} > /dev/stdout"
</code>
but every call creates a zombie because the fork created for the shell is not waited for.
i patched command.c to wait for the fork and it works. should i create a patch or is for some reason this behavior intended?
My guess is yes and no.
Not waiting (as in actually blocking) is intended.
I suspect we should periodically (or at least at the next run command) try to get rid of all zombies though.
Nicolas George
2015-04-15 08:00:31 UTC
Permalink
Post by Reimar Döffinger
I suspect we should periodically (or at least at the next run command) try
to get rid of all zombies though.
There is already this in the code:

#ifndef __MINGW32__
signal(SIGCHLD, child_sighandler);
#endif

#ifndef __MINGW32__
static void child_sighandler(int x)
{
pid_t pid;
do {
pid = waitpid(-1, NULL, WNOHANG);
} while (pid > 0);
}
#endif

So zombies should be reaped.

(As a side note, setting SIGCHLD to SIG_IGN would have the same effect.)

Regards,
--
Nicolas George
Amir Hassan
2015-04-15 10:02:35 UTC
Permalink
Post by Nicolas George
#ifndef __MINGW32__
signal(SIGCHLD, child_sighandler);
#endif
#ifndef __MINGW32__
static void child_sighandler(int x)
{
pid_t pid;
do {
pid = waitpid(-1, NULL, WNOHANG);
} while (pid > 0);
}
#endif
So zombies should be reaped.
weird. with MPlayer SVN-r37386-snapshot-4.9.2 on wheezy/armv7l (BananaPi)
it definitely doesn't reap zombies. sorry, i won't find the time to
investigate more deeply because i switched to mpv for my project. anyway i
still think mplayer rocks. :)
Post by Nicolas George
(As a side note, setting SIGCHLD to SIG_IGN would have the same effect.)
Reimar Döffinger
2015-04-15 21:14:35 UTC
Permalink
Post by Nicolas George
(As a side note, setting SIGCHLD to SIG_IGN would have the same effect.)
I looked it up, we probably don't use that is it is an almost-recent
addition to POSIX.
2.4 Linux kernels and FreeBSD before 5 were explicitly mentioned
as not supporting it.
Reimar Döffinger
2015-04-15 21:56:20 UTC
Permalink
Post by Reimar Döffinger
Post by Nicolas George
(As a side note, setting SIGCHLD to SIG_IGN would have the same effect.)
I looked it up, we probably don't use that is it is an almost-recent
addition to POSIX.
2.4 Linux kernels and FreeBSD before 5 were explicitly mentioned
as not supporting it.
Also, I looked into the reported problem:
it does in fact exist.
The signal handler gets reset to default each time.
This meant we handled only the first child process exiting
(so anyone testing things only once would think it worked).
I've fixed that now in r37387.

Loading...