2008/1/12 Roberto A. Foglietta <[EMAIL PROTECTED]>:
> 2008/1/12, Tallam, Sreenivas <[EMAIL PROTECTED]>:
>> Hi All,
>>
>> This has been discussed in the forum before but all of them were focused
>> with a busybox version lower than what I am using
>> So I am asking this question to the yet again, please bear with me
>>
>
> I have the same problem with 1.2.2.1 but at this time I am ignoring
> it because I can live with it. What is your problem apart the warning
> message?
>
I have ported cttyhack into 1.2.2.1.
It was a easy job but I would like the patch attached would be added here
http://busybox.net/downloads/fixes-1.2.2.1-foglietta/
Thanks,
--
/roberto
diff -pruN busybox-1.2.2.1/shell/Config.in busybox-1.2.2.1.cttyhack/shell/Config.in
--- busybox-1.2.2.1/shell/Config.in 2006-07-01 00:42:05.000000000 +0200
+++ busybox-1.2.2.1.cttyhack/shell/Config.in 2008-07-03 14:26:57.039108000 +0200
@@ -240,6 +240,26 @@ config CONFIG_FEATURE_SH_STANDALONE_SHEL
that exact location with that exact name, this option will not work at
all.
+config CONFIG_CTTYHACK
+ bool "cttyhack"
+ default n
+ help
+ One common problem reported on the mailing list is "can't access tty;
+ job control turned off" error message which typically appears when
+ one tries to use shell with stdin/stdout opened to /dev/console.
+ This device is special - it cannot be a controlling tty.
+
+ Proper solution is to use correct device instead of /dev/console.
+
+ cttyhack provides "quick and dirty" solution to this problem.
+ It analyzes stdin with various ioctls, trying to determine whether
+ it is a /dev/ttyN or /dev/ttySN (virtual terminal or serial line).
+ If it detects one, it closes stdin/out/err and reopens that device.
+ Then it executes given program. Usage example for /etc/inittab
+ (for busybox init):
+
+ ::respawn:/bin/cttyhack /bin/sh
+
config CONFIG_FEATURE_COMMAND_EDITING
bool "Command line editing"
default n
diff -pruN busybox-1.2.2.1/shell/cttyhack.c busybox-1.2.2.1.cttyhack/shell/cttyhack.c
--- busybox-1.2.2.1/shell/cttyhack.c 1970-01-01 01:00:00.000000000 +0100
+++ busybox-1.2.2.1.cttyhack/shell/cttyhack.c 2008-07-03 14:45:39.185555000 +0200
@@ -0,0 +1,76 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Licensed under GPLv2
+ *
+ * Copyright (c) 2007 Denys Vlasenko <[EMAIL PROTECTED]>
+ */
+#include "libbb.h"
+
+/* From <linux/vt.h> */
+struct vt_stat {
+ unsigned short v_active; /* active vt */
+ unsigned short v_signal; /* signal to send */
+ unsigned short v_state; /* vt bitmask */
+};
+enum { VT_GETSTATE = 0x5603 }; /* get global vt state info */
+
+/* From <linux/serial.h> */
+struct serial_struct {
+ int type;
+ int line;
+ unsigned int port;
+ int irq;
+ int flags;
+ int xmit_fifo_size;
+ int custom_divisor;
+ int baud_base;
+ unsigned short close_delay;
+ char io_type;
+ char reserved_char[1];
+ int hub6;
+ unsigned short closing_wait; /* time to wait before closing */
+ unsigned short closing_wait2; /* no longer used... */
+ unsigned char *iomem_base;
+ unsigned short iomem_reg_shift;
+ unsigned int port_high;
+ unsigned long iomap_base; /* cookie passed into ioremap */
+ int reserved[1];
+};
+
+int cttyhack_main(int argc, char **argv)
+{
+ int fd;
+ char console[sizeof(int)*3 + 16];
+ union {
+ struct vt_stat vt;
+ struct serial_struct sr;
+ char paranoia[sizeof(struct serial_struct) * 3];
+ } u;
+
+ if (!*++argv) {
+ bb_show_usage();
+ }
+
+ strcpy(console, "/dev/tty");
+ if (ioctl(0, TIOCGSERIAL, &u.sr) == 0) {
+ /* this is a serial console */
+ sprintf(console + 8, "S%d", u.sr.line);
+ } else if (ioctl(0, VT_GETSTATE, &u.vt) == 0) {
+ /* this is linux virtual tty */
+ sprintf(console + 8, "S%d" + 1, u.vt.v_active);
+ }
+
+ if (console[8]) {
+ fd = bb_xopen(console, O_RDWR);
+ //bb_error_msg("switching to '%s'", console);
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ while (fd > 2) close(fd--);
+ /* Some other session may have it as ctty. Steal it from them */
+ ioctl(0, TIOCSCTTY, 1);
+ }
+
+ execvp(argv[0], argv);
+ bb_perror_msg_and_die("cannot exec '%s'", argv[0]);
+}
diff -pruN busybox-1.2.2.1/shell/Makefile.in busybox-1.2.2.1.cttyhack/shell/Makefile.in
--- busybox-1.2.2.1/shell/Makefile.in 2006-07-01 00:42:05.000000000 +0200
+++ busybox-1.2.2.1.cttyhack/shell/Makefile.in 2008-07-03 13:50:41.928699000 +0200
@@ -15,6 +15,7 @@ SHELLT-$(CONFIG_ASH) += ash.o
SHELLT-$(CONFIG_HUSH) += hush.o
SHELLT-$(CONFIG_LASH) += lash.o
SHELLT-$(CONFIG_MSH) += msh.o
+SHELLT-$(CONFIG_CTTYHACK) += cttyhack.o
SHELLT-$(CONFIG_FEATURE_COMMAND_EDITING) += cmdedit.o
ifneq ($(strip $(SHELLT-y)),)
diff -pru busybox-1.2.2.1/include/applets.h busybox-1.2.2.1_cttyhack/include/applets.h
--- busybox-1.2.2.1/include/applets.h 2008-07-03 15:54:27.940032135 +0200
+++ busybox-1.2.2.1_cttyhack/include/applets.h 2008-07-03 15:53:37.957628882 +0200
@@ -79,6 +78,7 @@ USE_CP(APPLET(cp, _BB_DIR_BIN, _BB_SUID_
USE_CPIO(APPLET(cpio, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
USE_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS))
+USE_CTTYHACK(APPLET_NOUSAGE(cttyhack, cttyhack, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_CUT(APPLET(cut, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox