vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi! 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. >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* 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). Kind regards, Hannah. |