[MPlayer-dev-eng] PATCH: signal handling in gmplayer, immediate mode in tvi_v4l, wrong warning for tv:// MRLs

Sergey Pinaev dfo at antex.ru
Tue May 20 11:36:07 CEST 2003


hi.
On Tue, 20 May 2003 11:22:14 +0200
Arpi <arpi at thot.banki.hu> wrote:

>> 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);
    }
}

>> 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

btw, in mencoder you forgot to declare volatile "at_eof" and "interrupted".

-- 
mail="Sergey Pinaev <dfo at antex.ru>"
url="http://`echo $mail | sed 's/.* <\(.*\)>/\1/' | sed 's/@/./'`"



More information about the MPlayer-dev-eng mailing list