diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-10 07:06:04 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-10 07:06:04 +0000 |
commit | 2afabe8b830cc8c33f5f1984767af4b8dc54803b (patch) | |
tree | 2647f259f9584d874dca8a784af4dd87df6db57e /shell | |
parent | 191836845e4551fe6191dc0d43b45a0232bff8be (diff) | |
download | busybox-w32-2afabe8b830cc8c33f5f1984767af4b8dc54803b.tar.gz busybox-w32-2afabe8b830cc8c33f5f1984767af4b8dc54803b.tar.bz2 busybox-w32-2afabe8b830cc8c33f5f1984767af4b8dc54803b.zip |
init: remove superfluous forks and messing up with argv[0]
cttyhack: add stealing of ctty
Diffstat (limited to 'shell')
-rw-r--r-- | shell/cttyhack.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/shell/cttyhack.c b/shell/cttyhack.c index cdd0ed1d6..915ab5142 100644 --- a/shell/cttyhack.c +++ b/shell/cttyhack.c | |||
@@ -1,16 +1,18 @@ | |||
1 | /* This code is adapted from busybox project | 1 | /* vi: set sw=4 ts=4: */ |
2 | * | 2 | /* |
3 | * Licensed under GPLv2 | 3 | * Licensed under GPLv2 |
4 | * | ||
5 | * Copyright (c) 2007 Denys Vlasenko <vda.linux@googlemail.com> | ||
4 | */ | 6 | */ |
5 | #include "libbb.h" | 7 | #include "libbb.h" |
6 | 8 | ||
7 | /* From <linux/vt.h> */ | 9 | /* From <linux/vt.h> */ |
8 | struct vt_stat { | 10 | struct vt_stat { |
9 | unsigned short v_active; /* active vt */ | 11 | unsigned short v_active; /* active vt */ |
10 | unsigned short v_signal; /* signal to send */ | 12 | unsigned short v_signal; /* signal to send */ |
11 | unsigned short v_state; /* vt bitmask */ | 13 | unsigned short v_state; /* vt bitmask */ |
12 | }; | 14 | }; |
13 | enum { VT_GETSTATE = 0x5603 }; /* get global vt state info */ | 15 | enum { VT_GETSTATE = 0x5603 }; /* get global vt state info */ |
14 | 16 | ||
15 | /* From <linux/serial.h> */ | 17 | /* From <linux/serial.h> */ |
16 | struct serial_struct { | 18 | struct serial_struct { |
@@ -26,8 +28,8 @@ struct serial_struct { | |||
26 | char io_type; | 28 | char io_type; |
27 | char reserved_char[1]; | 29 | char reserved_char[1]; |
28 | int hub6; | 30 | int hub6; |
29 | unsigned short closing_wait; /* time to wait before closing */ | 31 | unsigned short closing_wait; /* time to wait before closing */ |
30 | unsigned short closing_wait2; /* no longer used... */ | 32 | unsigned short closing_wait2; /* no longer used... */ |
31 | unsigned char *iomem_base; | 33 | unsigned char *iomem_base; |
32 | unsigned short iomem_reg_shift; | 34 | unsigned short iomem_reg_shift; |
33 | unsigned int port_high; | 35 | unsigned int port_high; |
@@ -66,8 +68,10 @@ int cttyhack_main(int argc, char **argv) | |||
66 | dup2(fd, 1); | 68 | dup2(fd, 1); |
67 | dup2(fd, 2); | 69 | dup2(fd, 2); |
68 | while (fd > 2) close(fd--); | 70 | while (fd > 2) close(fd--); |
71 | /* Some other session may have it as ctty. Steal it from them */ | ||
72 | ioctl(0, TIOCSCTTY, 1) | ||
69 | } | 73 | } |
70 | 74 | ||
71 | execvp(argv[0], argv); | 75 | BB_EXECVP(argv[0], argv); |
72 | bb_perror_msg_and_die("cannot exec '%s'", argv[0]); | 76 | bb_perror_msg_and_die("cannot exec '%s'", argv[0]); |
73 | } | 77 | } |