Probems opening /dev/tty when running from gmenu2x

David Kuehling dvdkhlng at
Mon Dec 27 06:16:39 EST 2010

>>>>> "Xiangfu" == Xiangfu Liu <xiangfu at> writes:

> On 12/27/2010 05:30 PM, David Kuehling wrote:
>>> > one question about ioctl(1, TIOCSCTTY, (char *)1); the first "1"
>>> means > /dev/tty1, right??  what is the meaning of "(char *)1"?
>> It means stdout (the file descriptor, not the stream).  As Alan
>> pointed out, we could (and should) replace this with constant
>> STDOUT_FILENO as defined in unistd.h

> then I have another question. :) why you pass "STDOUT" to "ioctl(1,
> TIOCSCTTY, ...)", I cann't find any document about "ioctl(1,
> TIOCSCTTY, ...)" .

Because standard input/output is connected to the linux terminal device
(in this case /dev/tty0 since gmenu2x was started by init for the first

When SDL initialized its keyboard input system, it issues
ioctl(fd,TIOSCTTY,0) to the terminal device, disabling it as controlling
terminal.  ioctl(1,TIOSCTTY,1) undoes that, but seems to only work if we
create a new session via setsid() first.

does that answer your question?


GnuPG public key:
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the discussion mailing list