[FFmpeg-user] ffmpeg is being immediately terminated after receive SIGINT twice

chobits mr.chobits at gmail.com
Wed Mar 27 07:19:17 CET 2013

When ffmpeg receive SIGINT twice, it should quit from blocked
operation and perform normal exit sequence (e.g: write trailer & close
file). ffmpeg will print something like "XXXX: Immediate exit
requested". But when I build ffmpeg-1.1.3 on 64bit Ubuntu 12.04, it is
being terminated after receive SIGINT twice. In this case, encoded
file may be corrupted. It found this is due to signal() in ffmpeg.c.
According to man page
 "(System V) when a handler that was established using signal() was
invoked by the delivery of a signal, the disposition of the signal
would be reset to SIG_DFL"
"On glibc 2 and later, if the _BSD_SOURCE feature test macro is not
defined, then signal() provides System V semantics.   (The  default
implicit definition  of  _BSD_SOURCE is not provided if one invokes
gcc(1) in one of its standard modes (-std=xxx or -ansi)"

In my system, ffmpeg was build with "gcc -std=c99". Because SIGINT
handler was reset to SIG_DFL after ffmpeg received 1st SIGINT, 2nd
SIGINT cause ffmpeg immediately terminated (instead of cause ffmpeg
exit from blocked operation)

replace signal() with sigaction() will solve this problem

More information about the ffmpeg-user mailing list