todd@ivucsb.UUCP (Todd Day) (02/15/89)
I am having a problem getting a program to catch the SIGPHONE signal. Here is a short bit of my program: extern int wakeup(); main() { signal(SIGPHONE, wakeup); /* catch SIGPHONE (SIG_IGN by default)*/ printf("before pause\n"); pause(); /* take a siesta until phone rings */ signal(SIGPHONE, SIG_IGN); /* ignore anymore phone changes */ } /* wakeup is a dummy so we can catch phone changes */ int wakeup() { printf("SIGPHONE\n"); } The output of this program simply produces: before pause and then it hangs. That's fine, but when the phone rings, or when I toggle the status of the line, my program still hangs without further output. It appears that my program never gets SIGPHONE. However, the phone manager says VOICE 1:<RING, so it appears that the signal is getting to ph. Anyone know what I'm doing wrong? Do I have to have a ppid of 1 like ph? How do I get ppid of 1? Todd Day | ..!pyramid!nessus!ivucsb!todd | todd@ivucsb.UUCP ^^^^^^ new! ^^^^^^^^^^^ maybe?
lenny@icus.islp.ny.us (Lenny Tropiano) (02/18/89)
In article <532@ivucsb.UUCP> todd@ivucsb.UUCP (Todd Day) writes: |>I am having a problem getting a program to catch the SIGPHONE signal. |>Here is a short bit of my program: |> ... I did some testing with this a while back. As it turns out only ONE PROCESS will be sent a SIGPHONE signal on the change of the phone status. It is the last process to open the /dev/ph* devices. For your program to work, it will have to open("/dev/ph0",O_RDWR|O_NDELAY)... Here's your code ... with the appropriate modification ... extern int wakeup(); main() { int fd; signal(SIGPHONE, wakeup); /* catch SIGPHONE (SIG_IGN by default)*/ if ((fd = open("/dev/ph0",O_RDWR|O_NDELAY)) == -1) { perror("open()"); exit(1); } printf("before pause\n"); pause(); /* take a siesta until phone rings */ signal(SIGPHONE, SIG_IGN); /* ignore anymore phone changes */ } /* wakeup is a dummy so we can catch phone changes */ int wakeup() { printf("SIGPHONE\n"); } -- Lenny Tropiano ICUS Software Systems [w] +1 (516) 582-5525 lenny@icus.islp.ny.us Telex; 154232428 ICUS [h] +1 (516) 968-8576 {talcott,decuac,boulder,hombre,pacbell,sbcs}!icus!lenny attmail!icus!lenny ICUS Software Systems -- PO Box 1; Islip Terrace, NY 11752