Can a (non-)controlling process detach its controlling terminal by closing its file descriptor?
Clash Royale CLAN TAG#URR8PPP
In a process session with a controlling terminal,
if the controlling process closes the file descriptor of the controlling terminal, does the process session become detached from the controlling terminal, i.e. not have any controlling terminal?
What if a non-controlling process in the session closes the file descriptor of the controlling terminal?
Thanks.
session controlling-terminal
add a comment |
In a process session with a controlling terminal,
if the controlling process closes the file descriptor of the controlling terminal, does the process session become detached from the controlling terminal, i.e. not have any controlling terminal?
What if a non-controlling process in the session closes the file descriptor of the controlling terminal?
Thanks.
session controlling-terminal
Stephen Kitt actually addressed this in two of Tim's questions in 2018: unix.stackexchange.com/questions/446211 and unix.stackexchange.com/questions/447197 .
– JdeBP
Jan 4 at 3:52
Do you mean the answers to both questions are no?
– Tim
Jan 4 at 4:03
That is correct the answers to both questions are no. Closing the handles does not disassociate the process from its terminal. The terminal still maintains ownership of the processes created under it, unless forked or nohup ed, or stopped and bg ed. This is maintained through the pid parent hierarchy.
– Strom
Jan 4 at 4:11
That is yet another example of why one should always take comment answers with a large sackful of salt. As can be found in unix.stackexchange.com/questions/446211 , the "unless nohup ed" is yet more incorrect information (obviously so, if one considers whatnohup
does), and as can be found in unix.stackexchange.com/questions/405755 , so too is "maintained through the pid parent hierarchy". Tim has already asked about stopped/background processes in many questions such as unix.stackexchange.com/questions/490986 and unix.stackexchange.com/questions/396840 .
– JdeBP
Jan 4 at 8:53
add a comment |
In a process session with a controlling terminal,
if the controlling process closes the file descriptor of the controlling terminal, does the process session become detached from the controlling terminal, i.e. not have any controlling terminal?
What if a non-controlling process in the session closes the file descriptor of the controlling terminal?
Thanks.
session controlling-terminal
In a process session with a controlling terminal,
if the controlling process closes the file descriptor of the controlling terminal, does the process session become detached from the controlling terminal, i.e. not have any controlling terminal?
What if a non-controlling process in the session closes the file descriptor of the controlling terminal?
Thanks.
session controlling-terminal
session controlling-terminal
asked Jan 4 at 3:19
TimTim
26.4k75248457
26.4k75248457
Stephen Kitt actually addressed this in two of Tim's questions in 2018: unix.stackexchange.com/questions/446211 and unix.stackexchange.com/questions/447197 .
– JdeBP
Jan 4 at 3:52
Do you mean the answers to both questions are no?
– Tim
Jan 4 at 4:03
That is correct the answers to both questions are no. Closing the handles does not disassociate the process from its terminal. The terminal still maintains ownership of the processes created under it, unless forked or nohup ed, or stopped and bg ed. This is maintained through the pid parent hierarchy.
– Strom
Jan 4 at 4:11
That is yet another example of why one should always take comment answers with a large sackful of salt. As can be found in unix.stackexchange.com/questions/446211 , the "unless nohup ed" is yet more incorrect information (obviously so, if one considers whatnohup
does), and as can be found in unix.stackexchange.com/questions/405755 , so too is "maintained through the pid parent hierarchy". Tim has already asked about stopped/background processes in many questions such as unix.stackexchange.com/questions/490986 and unix.stackexchange.com/questions/396840 .
– JdeBP
Jan 4 at 8:53
add a comment |
Stephen Kitt actually addressed this in two of Tim's questions in 2018: unix.stackexchange.com/questions/446211 and unix.stackexchange.com/questions/447197 .
– JdeBP
Jan 4 at 3:52
Do you mean the answers to both questions are no?
– Tim
Jan 4 at 4:03
That is correct the answers to both questions are no. Closing the handles does not disassociate the process from its terminal. The terminal still maintains ownership of the processes created under it, unless forked or nohup ed, or stopped and bg ed. This is maintained through the pid parent hierarchy.
– Strom
Jan 4 at 4:11
That is yet another example of why one should always take comment answers with a large sackful of salt. As can be found in unix.stackexchange.com/questions/446211 , the "unless nohup ed" is yet more incorrect information (obviously so, if one considers whatnohup
does), and as can be found in unix.stackexchange.com/questions/405755 , so too is "maintained through the pid parent hierarchy". Tim has already asked about stopped/background processes in many questions such as unix.stackexchange.com/questions/490986 and unix.stackexchange.com/questions/396840 .
– JdeBP
Jan 4 at 8:53
Stephen Kitt actually addressed this in two of Tim's questions in 2018: unix.stackexchange.com/questions/446211 and unix.stackexchange.com/questions/447197 .
– JdeBP
Jan 4 at 3:52
Stephen Kitt actually addressed this in two of Tim's questions in 2018: unix.stackexchange.com/questions/446211 and unix.stackexchange.com/questions/447197 .
– JdeBP
Jan 4 at 3:52
Do you mean the answers to both questions are no?
– Tim
Jan 4 at 4:03
Do you mean the answers to both questions are no?
– Tim
Jan 4 at 4:03
That is correct the answers to both questions are no. Closing the handles does not disassociate the process from its terminal. The terminal still maintains ownership of the processes created under it, unless forked or nohup ed, or stopped and bg ed. This is maintained through the pid parent hierarchy.
– Strom
Jan 4 at 4:11
That is correct the answers to both questions are no. Closing the handles does not disassociate the process from its terminal. The terminal still maintains ownership of the processes created under it, unless forked or nohup ed, or stopped and bg ed. This is maintained through the pid parent hierarchy.
– Strom
Jan 4 at 4:11
That is yet another example of why one should always take comment answers with a large sackful of salt. As can be found in unix.stackexchange.com/questions/446211 , the "unless nohup ed" is yet more incorrect information (obviously so, if one considers what
nohup
does), and as can be found in unix.stackexchange.com/questions/405755 , so too is "maintained through the pid parent hierarchy". Tim has already asked about stopped/background processes in many questions such as unix.stackexchange.com/questions/490986 and unix.stackexchange.com/questions/396840 .– JdeBP
Jan 4 at 8:53
That is yet another example of why one should always take comment answers with a large sackful of salt. As can be found in unix.stackexchange.com/questions/446211 , the "unless nohup ed" is yet more incorrect information (obviously so, if one considers what
nohup
does), and as can be found in unix.stackexchange.com/questions/405755 , so too is "maintained through the pid parent hierarchy". Tim has already asked about stopped/background processes in many questions such as unix.stackexchange.com/questions/490986 and unix.stackexchange.com/questions/396840 .– JdeBP
Jan 4 at 8:53
add a comment |
1 Answer
1
active
oldest
votes
libc manual: "… All the processes in a session inherit the controlling terminal from the session leader.
A session leader that has control of a terminal is called the controlling process of that terminal. …"
According to typical "daemonize" scenario the only way to get rid of controlling terminal is to create new session. Closing file descriptors wouldn't do that.
Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
Jan 4 at 6:13
obsolete: stackoverflow.com/a/8777697/990047
– poige
Jan 4 at 6:21
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492372%2fcan-a-non-controlling-process-detach-its-controlling-terminal-by-closing-its-f%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
libc manual: "… All the processes in a session inherit the controlling terminal from the session leader.
A session leader that has control of a terminal is called the controlling process of that terminal. …"
According to typical "daemonize" scenario the only way to get rid of controlling terminal is to create new session. Closing file descriptors wouldn't do that.
Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
Jan 4 at 6:13
obsolete: stackoverflow.com/a/8777697/990047
– poige
Jan 4 at 6:21
add a comment |
libc manual: "… All the processes in a session inherit the controlling terminal from the session leader.
A session leader that has control of a terminal is called the controlling process of that terminal. …"
According to typical "daemonize" scenario the only way to get rid of controlling terminal is to create new session. Closing file descriptors wouldn't do that.
Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
Jan 4 at 6:13
obsolete: stackoverflow.com/a/8777697/990047
– poige
Jan 4 at 6:21
add a comment |
libc manual: "… All the processes in a session inherit the controlling terminal from the session leader.
A session leader that has control of a terminal is called the controlling process of that terminal. …"
According to typical "daemonize" scenario the only way to get rid of controlling terminal is to create new session. Closing file descriptors wouldn't do that.
libc manual: "… All the processes in a session inherit the controlling terminal from the session leader.
A session leader that has control of a terminal is called the controlling process of that terminal. …"
According to typical "daemonize" scenario the only way to get rid of controlling terminal is to create new session. Closing file descriptors wouldn't do that.
answered Jan 4 at 3:40
poigepoige
4,0621543
4,0621543
Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
Jan 4 at 6:13
obsolete: stackoverflow.com/a/8777697/990047
– poige
Jan 4 at 6:21
add a comment |
Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
Jan 4 at 6:13
obsolete: stackoverflow.com/a/8777697/990047
– poige
Jan 4 at 6:21
Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
Jan 4 at 6:13
Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
Jan 4 at 6:13
obsolete: stackoverflow.com/a/8777697/990047
– poige
Jan 4 at 6:21
obsolete: stackoverflow.com/a/8777697/990047
– poige
Jan 4 at 6:21
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492372%2fcan-a-non-controlling-process-detach-its-controlling-terminal-by-closing-its-f%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Stephen Kitt actually addressed this in two of Tim's questions in 2018: unix.stackexchange.com/questions/446211 and unix.stackexchange.com/questions/447197 .
– JdeBP
Jan 4 at 3:52
Do you mean the answers to both questions are no?
– Tim
Jan 4 at 4:03
That is correct the answers to both questions are no. Closing the handles does not disassociate the process from its terminal. The terminal still maintains ownership of the processes created under it, unless forked or nohup ed, or stopped and bg ed. This is maintained through the pid parent hierarchy.
– Strom
Jan 4 at 4:11
That is yet another example of why one should always take comment answers with a large sackful of salt. As can be found in unix.stackexchange.com/questions/446211 , the "unless nohup ed" is yet more incorrect information (obviously so, if one considers what
nohup
does), and as can be found in unix.stackexchange.com/questions/405755 , so too is "maintained through the pid parent hierarchy". Tim has already asked about stopped/background processes in many questions such as unix.stackexchange.com/questions/490986 and unix.stackexchange.com/questions/396840 .– JdeBP
Jan 4 at 8:53