Keeping an eye on hung system calls..

danny staple danny at
Sat Jun 10 19:13:24 BST 2006

On 06/06/06, Toby Corkindale <tjc at> wrote:
> Hi,
> I have a little app to make jpeg thumbnails out of video files. It's nothing
> special, it just spawns mplayer to get a jpeg out of the first frame..
> However I have a problem with mplayer occaisionally getting hung on some files
> it can't handle well, and never exitting.
> So, this lead me to wonder about methods of keeping an eye on system() calls.
> I was wondering.. perhaps this conundrum has already been solved? Or am I just
> going in totally the wrong direction?
> cheers,
> Toby


I may be missing something here, but I am pretty sure we acheived this
by using eval, storing the child pid in a var declared above, and
using SIGALM, with a handler that will then kill the child process by
its IP and die (which will mean the eval dies but not the whole code

There is this example from the perlipc man page (or perldoc page):

    eval {
        local $SIG{ALRM} = sub { die "alarm clock restart" };
        alarm 10;
        flock(FH, 2);   # blocking write lock
        alarm 0;

Your version would kill the child using its stored ip, before the
handler died. We used something like this to handle exactly what you
are describing at my previous job.

Danny Staple MBCS
(Full contact details available through website)

More information about the mailing list