schreiner@iravcl.ira.uka.de (10/02/89)
Here are setpgrp(2) and getpgrp(2) for MINIX. The shar archive contains four shar archives which contain the changes/files for ~/h, ~/mm, ~/fs, and libc.a. Two 'unused' function numbers are used for the system calls to avoid conflicts. The first raw implementation was made by Thomas Mohr while working on his multiple terminal emulator. This one should be POSIX compatible. We didn't tell TTY when a process group leader has called stepgrp(2) because his pgrp is already equal to his pid, nothing to 0. Credit must also be given to Johan W. Stevenson, he gave us some hints how to do the work. Ralf Wenk, using a friends account ----------------------- Cut here --------------------------------------------- echo x - fs.shar sed 's/^X//' > fs.shar << '/' Xecho x - misc.c.cdif Xsed 's/^X//' > misc.c.cdif << '/' XX*** misc.c Sun Oct 1 22:47:25 1989 XX--- /usr/sys/fs/misc.c Sun Oct 1 22:46:20 1989 XX*************** XX*** 7,13 **** XX * do_sync: perform the SYNC system call XX * do_fork: adjust the tables after MM has performed a FORK system call XX * do_exit: a process has exited; note that in the tables XX! * do_set: set uid or gid for some process XX * do_revive: revive a process that was waiting for something (e.g. TTY) XX */ XX XX--- 7,13 ---- XX * do_sync: perform the SYNC system call XX * do_fork: adjust the tables after MM has performed a FORK system call XX * do_exit: a process has exited; note that in the tables XX! * do_set: set uid or gid or pgrp for some process XX * do_revive: revive a process that was waiting for something (e.g. TTY) XX */ XX XX*************** XX*** 220,225 **** XX--- 220,231 ---- XX tfp->fp_effgid = (gid) eff_grp_id; XX tfp->fp_realgid = (gid) real_grp_id; XX } XX+ if (fs_call == SETPGRP) { XX+ /* Is this a process group leader ? */ XX+ if ( tfp->fp_pid != tfp->fp_pgrp ) XX+ tfp->fs_tty = 0; /* remove its control terminal */ XX+ tfp->fp_pgrp = pgrp; XX+ } XX return(OK); XX } XX X/ Xecho x - param.h.cdif Xsed 's/^X//' > param.h.cdif << '/' XX*** param.h Sun Oct 1 22:31:30 1989 XX--- /usr/sys/fs/param.h Sun Oct 1 19:01:18 1989 XX*************** XX*** 27,32 **** XX--- 27,33 ---- XX #define owner m.m1_i2 XX #define parent m.m1_i1 XX #define pathname m.m3_ca1 XX+ #define pgrp m.m1_i2 XX #define pid m.m1_i3 XX #define pro m.m1_i1 XX #define rd_only m.m1_i3 X/ Xecho x - table.c.cdif Xsed 's/^X//' > table.c.cdif << '/' XX*** table.c Sun Oct 1 22:31:39 1989 XX--- /usr/sys/fs/table.c Sun Oct 1 18:45:51 1989 XX*************** XX*** 82,89 **** XX do_set, /* 46 = setgid */ XX no_sys, /* 47 = getgid */ XX no_sys, /* 48 = sig */ XX! no_sys, /* 49 = unused */ XX! no_sys, /* 50 = unused */ XX no_sys, /* 51 = (acct) */ XX no_sys, /* 52 = (phys) */ XX no_sys, /* 53 = (lock) */ XX--- 82,89 ---- XX do_set, /* 46 = setgid */ XX no_sys, /* 47 = getgid */ XX no_sys, /* 48 = sig */ XX! do_set, /* 49 = setpgrp */ XX! no_sys, /* 50 = getpgrp */ XX no_sys, /* 51 = (acct) */ XX no_sys, /* 52 = (phys) */ XX no_sys, /* 53 = (lock) */ X/ / echo x - h.shar sed 's/^X//' > h.shar << '/' Xecho x - callnr.h.cdif Xsed 's/^X//' > callnr.h.cdif << '/' XX*** callnr.h Sun Oct 1 22:07:13 1989 XX--- /usr/sys/h/callnr.h Sun Oct 1 18:12:30 1989 XX*************** XX*** 37,42 **** XX--- 37,44 ---- XX #define SETGID 46 XX #define GETGID 47 XX #define SIGNAL 48 XX+ #define SETPGRP 49 XX+ #define GETPGRP 50 XX #define IOCTL 54 XX #define EXEC 59 XX #define UMASK 60 X/ / echo x - lib.shar sed 's/^X//' > lib.shar << '/' Xecho x - getpgrp.c Xsed 's/^X//' > getpgrp.c << '/' XX XXPUBLIC int getpgrp() XX{ XX return callm1(MM, GETPGRP, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); XX} X/ Xecho x - setpgrp.c Xsed 's/^X//' > setpgrp.c << '/' XX XXPUBLIC int setpgrp() XX{ XX return callm1(MM, SETPGRP, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); XX} X/ / echo x - mm.shar sed 's/^X//' > mm.shar << '/' Xecho x - getset.c.cdif Xsed 's/^X//' > getset.c.cdif << '/' XX*** getset.c Sun Oct 1 22:15:05 1989 XX--- /usr/sys/mm/getset.c Sun Oct 1 18:43:44 1989 XX*************** XX*** 1,4 **** XX--- 1,5 ---- XX /* This file handles the 4 system calls that get and set uids and gids. XX+ * Plus the two calls that get and set the process group. XX * It also handles getpid(). The code for each one is so tiny that it hardly XX * seemed worthwhile to make each a separate function. XX */ XX*************** XX*** 17,25 **** XX *===========================================================================*/ XX PUBLIC int do_getset() XX { XX! /* Handle GETUID, GETGID, GETPID, SETUID, SETGID. The three GETs return XX! * their primary results in 'r'. GETUID and GETGID also return secondary XX! * results (the effective IDs) in 'result2', which is returned to the user. XX */ XX XX register struct mproc *rmp = mp; XX--- 18,27 ---- XX *===========================================================================*/ XX PUBLIC int do_getset() XX { XX! /* Handle GETUID, GETGID, GETPID, SETUID, SETGID, SETPGRP, GETPGRP. The four XX! * GETs return their primary results in 'r'. GETUID and GETGID also return XX! * secondary results (the effective IDs) in 'result2', which is returned to XX! * the user. XX */ XX XX register struct mproc *rmp = mp; XX*************** XX*** 58,64 **** XX tell_fs(SETGID, who, grpid, grpid); XX r = OK; XX break; XX! } XX! XX! return(r); XX! } XX--- 60,76 ---- XX tell_fs(SETGID, who, grpid, grpid); XX r = OK; XX break; XX! XX! case SETPGRP: XX! r = rmp->mp_pid; XX! rmp->mp_procgrp = r; XX! tell_fs( SETPGRP, who, r, r ); XX! break; XX! XX! case GETPGRP: XX! r = rmp->mp_procgrp; XX! break; XX! } XX! XX! return(r); XX! } X/ Xecho x - table.c.cdif Xsed 's/^X//' > table.c.cdif << '/' XX*** table.c Sun Oct 1 22:15:10 1989 XX--- /usr/sys/mm/table.c Sun Oct 1 18:14:35 1989 XX*************** XX*** 79,86 **** XX do_getset, /* 46 = setgid */ XX do_getset, /* 47 = getgid */ XX do_signal, /* 48 = sig */ XX! no_sys, /* 49 = unused */ XX! no_sys, /* 50 = unused */ XX no_sys, /* 51 = (acct) */ XX no_sys, /* 52 = (phys) */ XX no_sys, /* 53 = (lock) */ XX--- 79,86 ---- XX do_getset, /* 46 = setgid */ XX do_getset, /* 47 = getgid */ XX do_signal, /* 48 = sig */ XX! do_getset, /* 49 = setpgrp */ XX! do_getset, /* 50 = getpgrp */ XX no_sys, /* 51 = (acct) */ XX no_sys, /* 52 = (phys) */ XX no_sys, /* 53 = (lock) */ X/ / exit 0