Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: caught signal 2
Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:
> >> dsyslog("PID = %d", getpid());
> >>
> >>to the SignalHandler() function in VDR/vdr.c. Maybe it gives you
> >>the process id of the process sending the signal - which might shed
> >>some more light on this.
> >
> > Ehh.... getpid will print the PID of VDR (in his example 2659), not?
> I'm not sure about that - maybe it prints the pid of the interrupting
> process.
Unfortunately not with signal() but it is possible with sigaction().
A test program may look as follows:
#include <stdio.h>
#include <signal.h>
#include <ucontext.h>
void my_signal_handler(int sig, siginfo_t *sigInfo, struct ucontext *scp) {
printf("siginfo->si_code = %d\n", sigInfo->si_code);
printf("siginfo->si_pid = %d\n", sigInfo->si_pid);
printf("siginfo->si_addr = %d\n", sigInfo->si_addr);
exit(0);
}
int main (int argc, char **argv) {
struct sigaction sa;
int i, j;
/* not this one!
sa.sa_handler = (void *)my_signal_handler;
*/
/* but these two */
sa.sa_sigaction = (void *)my_signal_handler;
sa.sa_flags = SA_SIGINFO;
sigaction (SIGINT, &sa, NULL);
/* endless loop */
while (1) {
sleep (60);
}
exit (0); /* to keep gcc happy */
}
The we run this program from a shell and press Ctrl-C:
hm@nathan:~/tmp> ./sighnd
siginfo->si_code = 128
siginfo->si_pid = 0
siginfo->si_addr = 0
Hmmm - not very useful. BUT - if we send the signal from a remote process
instead of the parent shell:
# echo $$
5881
# kill -INT 8743 (with 8743 being sighnd's PID)
and our program says
hm@nathan:~/tmp> ./sighnd
siginfo->si_code = 0
siginfo->si_pid = 5881
siginfo->si_addr = 5881
WOW!
So I'd suggest to replace the signal() calls in vdr.c by sigaction() and
dsyslog() the calling process's PID for debugging purposes :-))
I am still not sure about what happens on my box. It runs now 1.3.15 with
Werner's rc5 AC3 patches only. Plugins: remote, mp3, lcdproc. Seems to be
stable for now. But who knows.
--
All progress is based upon a universal innate desire on the part of
every organism to live beyond its income.
-- Samuel Butler
Home |
Main Index |
Thread Index