From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,bb6d74cd0429da99,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-02-23 22:04:21 PST Path: nntp.gmd.de!stern.fokus.gmd.de!gmdtub!cs.tu-berlin.de!fu-berlin.de!news.dfn.de!swiss.ans.net!howland.reston.ans.net!ix.netcom.com!netcom.com!dgm From: dgm@netcom.com (Darshan Maharana) Newsgroups: comp.unix.osf.osf1 Subject: Can't set pgid Message-ID: Date: 24 Feb 95 06:04:21 GMT Sender: dgm@netcom2.netcom.com Organization: NETCOM On-line Communication Services (408 261-4700 guest) X-Newsreader: TIN [version 1.2 PL1] Hi netters ! I am porting an application from Ultrix to Dec OSF/1 V.3.0. I require following process relationship : I have process which forks a child process. The parent has controlling terminal attached to it. So it is inherited by child. Now, I want to disassociate child from it's control terminal but want to keep (or put back) child in its parents process group. I reached a dead end trying this because of following reasons: 1) As for as I know there are two ways to disassociate a my child from its controlling terminal. a) using setsid(). But it makes my child a session and a group leader so I can not set it back to parents process group. b) opening /dev/tty (the controlling terminal) and using ioctl() to disassociate from the control terminal as follows: fd = open("/dev/tty", O_RDWR); ioctl(fd, TIOCNOTTY, (char *) 0); But this ioctl() has a side effect! It sets pgid (process group id) to 0. And you can not set it back by using setpgid(); 2) Since the application requires the parent to stay and fork as and when it is requested, I CAN NOT DO following: setsid() ; /* ...lose control terminal */ if(fork()) { /* parent process */ fd = open(tty_device, O_RDWR); ioctl(fd, TIOCSCTTY, 0); /* reaquire control terminal */ } else { /* continue as a child without control terminal with the same process group as parent */ } The problem with the code above is, next time if my parent wants to do the same thing , it will fail to loose its control terminal in setsid() since it is already a process and session leader. Any help will be highly appreciated. Thanx in advance - Darshan """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +-------+ Darshan Maharana | +-->+ | @ | Tel : | | o | Recycled thoughts ... | | [R] (408) 644-0338 | +<--+ | / \ | [W] (408) 649-4500 x 237| | ~ ~ | Fax:(408) 649 3288 | "If you think there is good in +-------+ dgm@netcom.com | everybody,you haven't met everybody" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" --