Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: dgm@netcom.com (Darshan Maharana)
Subject: Can't set pgid
Date: 24 Feb 95 06:04:21 GMT	[thread overview]
Message-ID: <dgmD4Hq79.1BC@netcom.com> (raw)

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 ...
|  <X>  |  [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"
    
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""    
             
-- 


             reply	other threads:[~1995-02-24  6:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-02-24  6:04 Darshan Maharana [this message]
1995-02-27 16:47 ` Can't set pgid Peter da Silva
1995-02-28 17:20 ` Phi H Truong
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox