Probems opening /dev/tty when running from gmenu2x
xiangfu at sharism.cc
Mon Dec 27 03:25:28 EST 2010
On 12/26/2010 01:43 AM, David Kuehling wrote:
>>>>>> "David" == David Kuehling <dvdkhlng at gmx.de> writes:
>>>>>> "Xiangfu" == Xiangfu Liu <xiangfu at sharism.cc> writes:
>>> when we run 'ash' 'bash' in gmenu2x it's always give me : /bin/ash :
>>> can't access tty; job control is turned off when start 'ash' 'bash'
>>> see the * KNOWN ISSUES)
>> Ok, after lots of trial and error, I now have a fix that works. It is
>> *ugly*, need to clean it up a bit, but anyways:
> Turns out there is a much more concise fix for the problem:
> int pid = setsid();
> tcsetpgrp(1, pid);
> ioctl(1, TIOCSCTTY, (char *)1);
just test your code. it works fine. but the tcsetpgrp(1, pid); it always return "-1".
seems we don't need it.
form the manual: http://pubs.opengroup.org/onlinepubs/009695399/functions/setsid.html
when we run 'setsid', pid have no controlling terminal, so 'tcsetpgrp' will fail.
one question about ioctl(1, TIOCSCTTY, (char *)1);
the first "1" means /dev/tty1, right??
what is the meaning of "(char *)1"?
> A properly formatted and commented patch is attached below (don't have
> commit access to gmenu2x).
now you can commit to gmenu2x. Wolfgang have added you to the "gmenu2x.git". :)
-- Qi RSS feed, http://en.qi-hardware.com/feed/rss20.xml --
More information about the discussion