CTRL-C - Make the hurting stop

Denys Vlasenko vda.linux at googlemail.com
Sun Dec 9 09:17:10 UTC 2007


On Friday 07 December 2007 10:44, Jason Farque wrote:
> Well known issue I realize, but I can't ctrl-c in my ttyS0 terminal
> window because it's not a controlling tty.  I've tried the methods of
> using getty, using cttyhack, and modifying ctty.c all to no avail.  I've
> read all that I can google up about it and have tried various
> work-arounds all to no avail.  I still can't ctrl-c in my terminal with
> busybox 1.8.2.
>
> I'm on a MIPS au1550 embedded system, big endian, using 2.6.12 linux
> kernel.  What I want is for Busybox 1.8.2 (which compiles and runs fine)
> to simply boot to a root command prompt on my system without a login
> prompt the way that my old Busybox 1.2.2.1 does.

I am attaching modified init.c and cttyhack.c.

What is changed: cttyhack:

cttyhack will execute ioctl(0, TIOCSCTTY, 1).
This means that it will try to steal controlling tty from any
other session which might have it as its ctty.

You may modify it like this for debugging:

    errno = 0;
    n = ioctl(0, TIOCSCTTY, 1);
    bb_perror_msg("TIOCSCTTY:%d, errno", n);

What does it report?


Next change is in init:

Removed pointless second fork in run(). It wasn't just pointless,
it actively prevented children from being session leaders.

Now any child will be a session leader because now run() does fork, setsid, 
and does *not* do second fork! This means than if you start your shell
as

::respawn:/bin/cttyhack /bin/sh

cttyhack _will be_ a session leader and will be able to steal ctty.


What is not changed: cttyhack is not doing setsid itself. Maybe it should:

+       setsid();
        fd = xopen(console, O_RDWR);


Please let me know how it works for you.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cttyhack.c
Type: text/x-csrc
Size: 1883 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20071209/480a7e2a/attachment-0004.c 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: init.c
Type: text/x-csrc
Size: 26021 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20071209/480a7e2a/attachment-0005.c 


More information about the busybox mailing list