|
Home > Archive > Unix Programming > January 2004 > Diassociating process from control terminal
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Diassociating process from control terminal
|
|
| xailer 2004-01-23, 5:14 pm |
| hi,I'm really stuck here
I started reading a book on network programming,but the problem is
that this book is for Unix systems and I run Linux.Furtunatelly,the
author spends some time describing Unix environment.But when it came
to Control terminals and diassociating daemons from them,I was lost.
For starters,Im not shure if I understand how terminal group ID in the
tty structure works.
Is each time a job-control shell forks a new process (foreground
job),the terminal group ID changed to refer to this job?Does that mean
that all other process groups associated with this terminal will be
blocked if they try to read or write to terminal?
Secondly,System V has a different method from 4.3BSD
In system V you call fork() and in child process you call setpgrp().I
tried it but when I checked ps -A ,process was still associated with
tty3
It worked with ioctl(fd,TIOCNOTTY,(char *)0);
so Im wondering why didn't call to setpgrp() manage to do the
same?Afterall,isn't the way to diassociate from Control terminal to
put process in process group whose group's ID is zero?
And that is what setpgrp() also did.
Does linux assign control terminal to process only if the process
group ID is zero (as is the case with 4.3DSD)?
thank you very much for taking the time
| |
| Fletcher Glenn 2004-01-23, 5:14 pm |
|
xailer wrote:quote:
> hi,I'm really stuck here
>
> I started reading a book on network programming,but the problem is
> that this book is for Unix systems and I run Linux.Furtunatelly,the
> author spends some time describing Unix environment.But when it came
> to Control terminals and diassociating daemons from them,I was lost.
>
> For starters,Im not shure if I understand how terminal group ID in the
> tty structure works.
> Is each time a job-control shell forks a new process (foreground
> job),the terminal group ID changed to refer to this job?Does that mean
> that all other process groups associated with this terminal will be
> blocked if they try to read or write to terminal?
>
> Secondly,System V has a different method from 4.3BSD
> In system V you call fork() and in child process you call setpgrp().I
> tried it but when I checked ps -A ,process was still associated with
> tty3
>
> It worked with ioctl(fd,TIOCNOTTY,(char *)0);
>
> so Im wondering why didn't call to setpgrp() manage to do the
> same?Afterall,isn't the way to diassociate from Control terminal to
> put process in process group whose group's ID is zero?
> And that is what setpgrp() also did.
>
> Does linux assign control terminal to process only if the process
> group ID is zero (as is the case with 4.3DSD)?
>
> thank you very much for taking the time
To disassociate from a controlling terminal, use the setsid() system call.
--
Fletcher Glenn
| |
| Fletcher Glenn 2004-01-23, 5:14 pm |
|
xailer wrote:quote:
> hi,I'm really stuck here
>
> I started reading a book on network programming,but the problem is
> that this book is for Unix systems and I run Linux.Furtunatelly,the
> author spends some time describing Unix environment.But when it came
> to Control terminals and diassociating daemons from them,I was lost.
>
> For starters,Im not shure if I understand how terminal group ID in the
> tty structure works.
> Is each time a job-control shell forks a new process (foreground
> job),the terminal group ID changed to refer to this job?Does that mean
> that all other process groups associated with this terminal will be
> blocked if they try to read or write to terminal?
>
> Secondly,System V has a different method from 4.3BSD
> In system V you call fork() and in child process you call setpgrp().I
> tried it but when I checked ps -A ,process was still associated with
> tty3
>
> It worked with ioctl(fd,TIOCNOTTY,(char *)0);
>
> so Im wondering why didn't call to setpgrp() manage to do the
> same?Afterall,isn't the way to diassociate from Control terminal to
> put process in process group whose group's ID is zero?
> And that is what setpgrp() also did.
>
> Does linux assign control terminal to process only if the process
> group ID is zero (as is the case with 4.3DSD)?
>
> thank you very much for taking the time
To disassociate from a controlling terminal, use the setsid() system call.
--
Fletcher Glenn
| |
| =?iso-8859-1?q?M=E5ns_Rullg=E5rd?= 2004-01-23, 5:14 pm |
| Fletcher Glenn <fletcher@removethisfoglight.com> writes:
quote:
> xailer wrote:
>
> To disassociate from a controlling terminal, use the setsid() system call.
Or daemon();
--
Måns Rullgård
mru@kth.se
| |
| =?iso-8859-1?q?M=E5ns_Rullg=E5rd?= 2004-01-23, 5:14 pm |
| Fletcher Glenn <fletcher@removethisfoglight.com> writes:
quote:
> xailer wrote:
>
> To disassociate from a controlling terminal, use the setsid() system call.
Or daemon();
--
Måns Rullgård
mru@kth.se
| |
| xailer 2004-01-23, 5:14 pm |
| mru@kth.se (Måns Rullgård) wrote in message news:<yw1xvfn7r4xn.fsf@ford.guide>...quote:
> Fletcher Glenn <fletcher@removethisfoglight.com> writes:
>
quote:
>
> Or daemon();
But suppose I want to do the same thing with setpgrp()?
For instance,setpgrp() simply calls setpgid(0,0);and so process does
get groups's ID to zero.But why is it necesarry that group ID be zero
in order for process to diassociate itself from a terminal?
And why did it work with ioctl(fd,TIOCNOTTY,(char *)0); but not with
setpgrp()?
thank you
| |
| xailer 2004-01-23, 5:14 pm |
| mru@kth.se (Måns Rullgård) wrote in message news:<yw1xvfn7r4xn.fsf@ford.guide>...quote:
> Fletcher Glenn <fletcher@removethisfoglight.com> writes:
>
quote:
>
> Or daemon();
But suppose I want to do the same thing with setpgrp()?
For instance,setpgrp() simply calls setpgid(0,0);and so process does
get groups's ID to zero.But why is it necesarry that group ID be zero
in order for process to diassociate itself from a terminal?
And why did it work with ioctl(fd,TIOCNOTTY,(char *)0); but not with
setpgrp()?
thank you
|
|
|
|
|