[BusyBox-cvs] busybox/init init.c,1.191,1.192
Erik Andersen
andersen at busybox.net
Tue Jul 29 06:33:18 UTC 2003
Update of /var/cvs/busybox/init
In directory winder:/tmp/cvs-serv8124/init
Modified Files:
init.c
Log Message:
Yang Xiaopeng writes:
>I'm sure that no user process use old root now, but when run "umount
>/old_root", it says:
> umount: /old_root: Device or resource busy
>
>I have tried to remount /proc within the new root *after* chroot, but
>get the same result.
>
>
I found the problem, I said that no user process use old root when run
my scripts, but
I'm wrong, actually there is a '3' fd open the file
"/old_root/dev/console". By adding
debug message in init/init.c, I found the problem: when init restart(in
exec_signal()),
before open the new terminal device, there is still a file opened(I
don't know which file it is), so the
terminal device(stdin) get fd '1', and the first dup(0)(stdout) return
'2', the second(stderr) return '3'.
I attach a simple patch to solve this problem.
Index: init.c
===================================================================
RCS file: /var/cvs/busybox/init/init.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- init.c 26 Jul 2003 06:24:25 -0000 1.191
+++ init.c 29 Jul 2003 06:33:12 -0000 1.192
@@ -735,6 +735,11 @@
sigaddset(&unblock_signals, SIGTSTP);
sigprocmask(SIG_UNBLOCK, &unblock_signals, NULL);
+ /* Close whatever files are open. */
+ close(0);
+ close(1);
+ close(2);
+
/* Open the new terminal device */
if ((device_open(a->terminal, O_RDWR)) < 0) {
if (stat(a->terminal, &sb) != 0) {
More information about the busybox-cvs
mailing list