bishop@ecsvax.UUCP (Alan Bishop) (09/17/87)
Below are some changes for the way MINIX handles process groups. First, process groups are now assigned differently. The process group leader's pid is used instead. (A process group leader is a process whose parent is INIT, or one that has done a setpgrp().) This is consistent with the way I've seen on other systems. Second, setpgrp() and getpgrp() are implemented. (Without parameters. This is like PC/IX, but unlike BSD.) The (trivial) library routines are included. Finally, the file system now keeps up with the process group and pid of all processes. It is informed by MM when a process does a setpgrp(). This is a first step in re-implementing the concept of control terminals under MINIX. Right now, /dev/tty points to the first character device that a process opens and assumptions are made about how to send SIGINT and SIGQUIT from the terminal driver. With this new information, the file system can be taught how to keep a table of control terminals vs. pids/process groups. However, this doesn't exist yet. I've been using these fixes and haven't had any problems. However, I'd love to hear about bugs. Below is a shell archive containing the fixes and a one line description of the changes made to each file. Everything SHOULD be relative to MINIX 1.2. NOTE: This WILL NOT unpack without modification under MINIX. All you have to do is deal with sed and chmod (non-numeric codes.) In fact, you may already have sed. alan ---lacerate here--- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by ecsvax!bishop on Wed Sep 16 21:42:23 EDT 1987 # Contents: Index fs:fproc.fix fs:misc.fix fs:param.fix fs:table.fix # lib:getpgrp.c lib:syslib.fix mm:forkexit.fix mm:getset.fix mm:table.fix # h:callnr.fix echo x - Index sed 's/^@//' > "Index" <<'@//E*O*F Index//' Index - This file fs:fproc.fix - Adds fields to the fproc structure fs:misc.fix - Added SETPGRP handing for fs fs:param.fix - Adds names for some fields passed. fs:table.fix - Added SETPGRP h:callnr.fix - Added SETPGRP and GETPGRP lib:getpgrp.c - Library function for SETPGRP and GETPGRP lib:syslib.fix - Changed comments ONLY. No code changes. mm:forkexit.fix - Re-did process group assignments. mm:getset.fix - Added SETPGRP and GETPGRP handling for mm mm:table.fix - Added SETPGRP and GETPGRP. @//E*O*F Index// chmod u=rw,g=r,o=r Index echo x - fs:fproc.fix sed 's/^@//' > "fs:fproc.fix" <<'@//E*O*F fs:fproc.fix//' 0a1,3 > /* MINIX 1.2 fproc.h */ > /* fp_pid and fp_procgrp added 09/08/87 AGB */ > 21a25,26 > int fp_pid; /* process id */ > int fp_procgrp; /* process group */ @//E*O*F fs:fproc.fix// chmod u=rw,g=r,o=r fs:fproc.fix echo x - fs:misc.fix sed 's/^@//' > "fs:misc.fix" <<'@//E*O*F fs:misc.fix//' 0a1,3 > /* MINIX 1.2 misc.c */ > /* Added support for SETPGRP and mods to fork 09/08/87 AGB */ > 11a15 > * do_setpgrp:set a process group equal to the pid 142,143c146,152 < /* Increase the counters in the 'filp' table. */ < cp = &fproc[child]; --- > cp = &fproc[child]; > > /* Fill in new process id and, if necessary, process group. */ > cp->fp_pid = pid; > if (parent = INIT_PROC_NR) cp->fp_procgrp = pid; > > /* Increase the counters in the 'filp' table. */ 235a245,260 > > /*===========================================================================* > * do_setpgrp * > *===========================================================================*/ > PUBLIC int do_setpgrp() > { > /* A process has changed its process group. Update the file system table. > * Only the memory manager may make this call. > */ > > if (who != MM_PROC_NR) return(ERROR); > > fproc[proc_slot].fp_procgrp = fproc[proc_slot].fp_pid; > > return(OK); > } @//E*O*F fs:misc.fix// chmod u=rw,g=r,o=r fs:misc.fix echo x - fs:param.fix sed 's/^@//' > "fs:param.fix" <<'@//E*O*F fs:param.fix//' 0a1,3 > /* MINIX 1.2 param.h */ > /* Added "pid" to pass a process PID in along with fork 09/08/87 AGB */ > 30c33,35 < #define pro m.m1_i1 --- > #define pid m.m1_i3 > #define pro m.m1_i1 > #define proc_slot m.m1_i1 @//E*O*F fs:param.fix// chmod u=rw,g=r,o=r fs:param.fix echo x - fs:table.fix sed 's/^@//' > "fs:table.fix" <<'@//E*O*F fs:table.fix//' 0a1,3 > /* MINIX 1.2 table.c */ > /* SETPGRP and GETPGRP added 09/08/87 AGB */ > 30a34 > extern do_setpgrp(); 105c109,112 < no_sys /* 68 = TASK_REPLY */ --- > no_sys, /* 68 = TASK_REPLY */ > > do_setpgrp, /* 69 = setpgrp */ > no_sys /* 70 = getpgrp */ @//E*O*F fs:table.fix// chmod u=rw,g=r,o=r fs:table.fix echo x - lib:getpgrp.c sed 's/^@//' > "lib:getpgrp.c" <<'@//E*O*F lib:getpgrp.c//' #include "../include/lib.h" PUBLIC int getpgrp() { return callm1(MM, GETPGRP, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); } PUBLIC int setpgrp() { return callm1(MM, SETPGRP, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); } @//E*O*F lib:getpgrp.c// chmod u=rw,g=r,o=r lib:getpgrp.c echo x - lib:syslib.fix sed 's/^@//' > "lib:syslib.fix" <<'@//E*O*F lib:syslib.fix//' 0a1,3 > /* MINIX 1.2 syslib.c */ > /* Added comments for new FORK and SETPGRP in tell_fs 09/08/87 AGB */ > 125c128 < * tell_fs(FORK, parent, child, 0) --- > * tell_fs(FORK, parent, child, pid) 129a133 > * tell_fs(SETPGRP, proc, 0, 0); @//E*O*F lib:syslib.fix// chmod u=rw,g=r,o=r lib:syslib.fix echo x - mm:forkexit.fix sed 's/^@//' > "mm:forkexit.fix" <<'@//E*O*F mm:forkexit.fix//' 0a1,4 > /* MINIX 1.2 forkexit.c */ > /* Process groups assigned by PID AGB 09/08/87 */ > /* Check not to reassign process groups AGB 09/16/87 */ > 28d31 < PRIVATE process_group = 1; /* next process grp to be assigned */ 83,85d85 < /* Set process group. */ < if (who == INIT_PROC_NR) rmc->mp_procgrp = process_group++; < 94a95 > /* Don't assign a pid for a process group in use AGB */ 99c100 < if (rmp->mp_pid == next_pid) { --- > if (rmp->mp_pid == next_pid || rmp->mp_procgrp == next_pid) { 106,108c107,112 < /* Tell kernel and file system about the (now successful) FORK. */ < sys_fork(who, child_nr, rmc->mp_pid); < tell_fs(FORK, who, child_nr, 0); --- > /* Set process group for INIT only. Others inherit it. */ > if (who == INIT_PROC_NR) rmc->mp_procgrp = next_pid; > > /* Tell kernel and file system about the (now successful) FORK. */ > sys_fork(who, child_nr, next_pid); > tell_fs(FORK, who, child_nr, next_pid); @//E*O*F mm:forkexit.fix// chmod u=rw,g=r,o=r mm:forkexit.fix echo x - mm:getset.fix sed 's/^@//' > "mm:getset.fix" <<'@//E*O*F mm:getset.fix//' 1,3c1,6 < /* This file handles the 4 system calls that get and set uids and gids. < * It also handles getpid(). The code for each one is so tiny that it hardly < * seemed worthwhile to make each a separate function. --- > /* MINIX 1.2 getset.c */ > /* Added getpgrp() and setpgrp() calls 09/08/87 AGB */ > > /* This file handles the 4 system calls that get and set uids and gids, > * getpid(), getpgrp(), and setpgrp(). The code for these is so tiny > * that they have been combined into one function. 61,64c64,74 < } < < return(r); < } --- > case GETPGRP: > r = rmp->mp_procgrp; > break; > case SETPGRP: > r = (rmp->mp_procgrp = rmp->mp_pid); > tell_fs(SETPGRP, who, 0, 0); > break; > } > > return(r); > } @//E*O*F mm:getset.fix// chmod u=rw,g=r,o=r mm:getset.fix echo x - mm:table.fix sed 's/^@//' > "mm:table.fix" <<'@//E*O*F mm:table.fix//' 0a1,3 > /* MINIX 1.2 table.c */ > /* SETPGRP and GETPGRP added 09/08/87 AGB */ > 98,99c101,104 < no_sys /* 68 = TASK_REPLY */ < }; --- > no_sys, /* 68 = TASK_REPLY */ > do_getset, /* 69 = SETPGRP */ > do_getset /* 70 = GETPGRP */ > }; @//E*O*F mm:table.fix// chmod u=rw,g=r,o=r mm:table.fix echo x - h:callnr.fix sed 's/^@//' > "h:callnr.fix" <<'@//E*O*F h:callnr.fix//' 1c1,4 < #define NCALLS 69 /* number of system calls allowed */ --- > /* MINIX 1.2 callnr.h */ > /* GETPGRP and SETPGRP added 09/08/87 AGB */ > > #define NCALLS 71 /* number of system calls allowed */ 50a54,60 > > /* The following are other system calls that are not part of the > * distributed MINIX 1.2. These numbers might should be something else. > */ > > #define SETPGRP 69 > #define GETPGRP 70 @//E*O*F h:callnr.fix// chmod u=rw,g=r,o=r h:callnr.fix exit 0
bishop@ecsvax.UUCP (Alan Bishop) (09/18/87)
There is a silly bug in the process group modifications that I posted. The following patched line in fs/misc.c if (parent = INIT_PROC_NR) cp->fp_procgrp = pid; should be (whoops) if (parent == INIT_PROC_NR) cp->fp_procgrp = pid; alan