[MPlayer-dev-eng] PATCH: signal handling in gmplayer, immediate mode in tvi_v4l, wrong warning for tv:// MRLs
Arpi
arpi at thot.banki.hu
Tue May 20 11:50:32 CEST 2003
Hi,
> >> according to "info libc" fprintf is nonreentrant and should not
> >> be used in signal handlers.
>
> A> so then what is the allowed method of printing from sighandler?
>
> The best practice is
> to write a handler that does nothing but set an external variable that
> the program checks regularly, and leave all serious work to the program.
> (c) info libc
>
> volatile int shithappens = 0;
>
> static void sighandler(int x) {
> shithappens = 1;
> }
>
> mainloop() {
> while(1) {
> if(shithappens) {
> mp_msg(...);
> exit(1);
> }
> }
shit means sigsegv or sigill or sigfpu and such things inside of codecs
(even in .dll or external libs) or other modules. there is no way to recover
from such error with just setting a variable.
the options are:
- clean exit from sighandler (a bit ugly), this is done now
(not thread safe, but who cares, mplayer is not multithreaded)
- do nothing (let the OS kill the app, without clean exit)
- longjmp() hack, to jump out from a sighandler (risky, hardly portable)
> >> btw, exit_sighandler in mplayer.c is "bloated" =)
> >> i think it should be implemented as is in mencoder.c
>
> A> no, mencoder does not have sighandler at all
> A> it does pure 'segfault' at errors with unclean exit
>
> huh?
> [dfo at dfo main]$ grep exit_sighandler mencoder.c
> static void exit_sighandler(int x){
> signal(SIGINT,exit_sighandler); // Interrupt from keyboard
> signal(SIGQUIT,exit_sighandler); // Quit from keyboard
> signal(SIGTERM,exit_sighandler); // kill
none of them are error handles, it only handles quit (ctrl+C).
on errors the OS will kill mplayer, without clean exit
> btw, in mencoder you forgot to declare volatile "at_eof" and "interrupted".
why should i do so?
A'rpi / Astral & ESP-team
--
Developer of MPlayer G2, the Movie Framework for all - http://www.MPlayerHQ.hu
More information about the MPlayer-dev-eng
mailing list