From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,ec409b3be619d0c1,start X-Google-Attributes: gidfc89c,public X-Google-Thread: 1164f8,ec409b3be619d0c1,start X-Google-Attributes: gid1164f8,public X-Google-Thread: f8b34,ec409b3be619d0c1,start X-Google-Attributes: gidf8b34,public X-Google-Thread: 10b612,ec409b3be619d0c1,start X-Google-Attributes: gid10b612,public From: john@iastate.edu (John Hascall) Subject: Bug? Control Terminal vs. Process Group Date: 1995/07/11 Message-ID: <3tud8e$nos@news.iastate.edu>#1/1 X-Deja-AN: 105998794 organization: Iowa State University, Ames, Iowa (USA) newsgroups: comp.unix.ultrix,comp.sys.dec,comp.unix.programmer,comp.infosystems.www.servers.unix The common practice in daemon writing (as, for example, in Stevens' _Unix Network Programming_) seems to be to change your process group and then drop your control terminal. I noticed that the CERN (3.0) httpd server, which follows this paradigm, was failing in its attempt to kill its children upon receipt of SIGTERM. I traced this to its process group being zero. It appears that, at least under Ultrix v4.3a, that dropping the control terminal sets the process group to zero (see example program and output below). My question is: * Is this a bug in Ultrix? * Is this just Ultrix choosing one of several alternative behaviours? * Is this standard behaviour and _Unix Network Programming_ etc. are in error? John ----------------------------------- results ----------------------------------- % pgrp process id is 26398 (parent which exits) process id is 26399 (child) process group is 26398 set process group returns ok process group is 26399 drop control tty returns ok <=== doing this process group is 0 <=== results in this?!? set process group returns ok process group is 26399 ----------------------------------- pgrp.c ------------------------------------ #include #include #include char * ok[] = {"error", "ok"}; #define OK(n) ok[n+1] int main(argc, argv) int argc; char ** argv; { int fd; printf("process id is %u\n", getpid()); if (fork() != 0) _exit(0); printf("process id is %u\n", getpid()); printf("process group is %u\n", getpgrp(0)); printf("set process group returns %s\n", OK(setpgrp(0, getpid()))); printf("process group is %u\n", getpgrp(0)); fd = open("/dev/tty", O_RDWR); printf("drop control tty returns %s\n", OK(ioctl(fd, TIOCNOTTY, (char*)NULL))); close(fd); printf("process group is %u\n", getpgrp(0)); printf("set process group returns %s\n", OK(setpgrp(0, getpid()))); printf("process group is %u\n", getpgrp(0)); return (0); } -- John Hascall ``An ill-chosen word is the fool's messenger.'' Moderator, comp.unix.wizards Systems Software Engineer, ISU Comp Center + Ames, IA 50011 + 515/294-9551 My Homepage