commit 3b6191b4d71e88a43dbf6c17a19b4a0def33e9e6
parent e832f4f4cb7e22ff6424a75f1fafb30c74e7caa3
Author: leitner <leitner>
Date: Wed, 7 Nov 2001 15:41:06 +0000
make each watched process his own process group
Diffstat:
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/CHANGES b/CHANGES
@@ -1,3 +1,7 @@
+0.5.1:
+ cut&paste error, set wrong variable to 0 for keyboard request.
+ Thanks, Schulti.
+
0.5:
add "log" subdirectory (see README).
get rid of stdio and *printf and switch to routines from libowfat.
diff --git a/minit.c b/minit.c
@@ -12,6 +12,7 @@
#include <sys/wait.h>
#include <stdio.h>
#include <linux/kd.h>
+#include <sys/ioctl.h>
#include "fmt.h"
#define MINITROOT "/etc/minit"
@@ -19,6 +20,8 @@
#undef printf
extern int printf(const char *format,...);
+static int i_am_init;
+
extern int openreadclose(char *fn, char **buf, unsigned long *len);
extern char **split(char *buf,int c,int *len,int plus,int ofs);
@@ -139,6 +142,23 @@ again:
goto again;
case 0:
/* child */
+
+ if (i_am_init) {
+ int fd;
+ ioctl(0, TIOCNOTTY, 0);
+ setsid();
+ if ((fd=open("/dev/console",O_RDWR|O_NOCTTY))>=0) {
+ dup2(fd,0);
+ dup2(fd,1);
+ dup2(fd,2);
+ ioctl(0, TIOCSCTTY, 1);
+ tcsetpgrp(0, getpgrp());
+ }
+ }
+ close(3);
+ close(4);
+ close(5);
+ close(6);
if (pause) {
struct timespec req;
req.tv_sec=0;
@@ -310,6 +330,7 @@ main(int argc, char *argv[]) {
if (getpid()==1) {
int fd;
+ i_am_init=1;
reboot(0);
if ((fd=open("/dev/tty0",O_RDWR|O_NOCTTY))) {
ioctl(fd, KDSIGACCEPT, SIGWINCH);