vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello, Dasn! I was advised that my earlier response might feel offensive to some, perhaps you too. If so, I apologize for it. I didn't meen to offend, but to be humorous, but probably I failed. On Thu, May 08, 2008 at 02:45:17PM +0200, Hannah Schroeter wrote: >On Thu, May 08, 2008 at 07:24:19AM +0800, Dasn wrote: >>On 05/05/08 16:00 +0200, Hannah Schroeter wrote: >>> After reading the kernel sources about this, I think the definition in >>> <sys/ttycom.h> is probably in error and it should be >>> #define TIOCSIG _IOW('t', 95, int) >>> ^^^^ ^^^ >>> Strangely, the xterm sources don't reference TIOCSIG, so I don't know >>> how xterm implements the send SIGfoo menu functions instead. >>> >But I cannot find any clues about it in pty(4). >>> >The code: >>> > int sig = SIGTERM; >>> > ioctl(pty_master, TIOCSIG, &sig) ; >>> That usage should be ok, and perhaps would work if you patched >>> <sys/ttycom.h> appropriately (recompile kernel, reboot, recompile your >>> app). >>Thank you, guys. After applying the patch, >That patch (cleaned up, of course) has been committed to the tree >(-current) in-between, as I've seen. >>the >> int sig = SIGTERM; >> ioctl(pty_master, TIOCSIG, &sig) ; >>works without error, but the signal sent by TIOCSIG has no effect unless >>the read(2) operation occurs on the pty_master. That is, if I want to use >>TIOCSIG to send the signal, I must read(2) from pty_master first, then >>ioctl the signal with TIOCSIG request, right? >I wonder. As I read the kernel code, the signal is sent to the >foreground process group of the matching tty that have a controlling >terminal immediately during executing the ioctl call. This stands. I'm not sure whether the effect you did observe might stem from. However, I haven't written an own test to confirm it (or to find what might go wrong or whatever). >>As the TIOCSIG has no documentations, I'm not sure whether it's a bug or >>feature... >The documentation is contained in the files whose name ends with .c and >.h. *g* And as said, if that (I guess) has felt offensive, I apologize. >The code in tty_pty.c, function ptyioctl, case TIOCSIG, is relatively >straightforward: > if (*(unsigned int *)data >= NSIG) > return(EINVAL); > if ((tp->t_lflag&NOFLSH) == 0) > ttyflush(tp, FREAD|FWRITE); > pgsignal(tp->t_pgrp, *(unsigned int *)data, 1); > if ((*(unsigned int *)data == SIGINFO) && > ((tp->t_lflag&NOKERNINFO) == 0)) > ttyinfo(tp); > return(0); >The pgsignal posts the signal to the process group. (And pgsignal is >documented in section 9). In addition, I don't see how ttyflush, or anything else could cause the effect to delay delivery of the signal up to the next read from the pty master (which you observed, if I understood you correctly). Kind regards, Hannah. |