Can a (non-)controlling process detach its controlling terminal by closing its file descriptor?












1














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.










share|improve this question






















  • 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
    yesterday










  • Do you mean the answers to both questions are no?
    – Tim
    yesterday










  • 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
    yesterday












  • 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
    20 hours ago
















1














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.










share|improve this question






















  • 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
    yesterday










  • Do you mean the answers to both questions are no?
    – Tim
    yesterday










  • 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
    yesterday












  • 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
    20 hours ago














1












1








1







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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Tim

26.1k74246455




26.1k74246455












  • 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
    yesterday










  • Do you mean the answers to both questions are no?
    – Tim
    yesterday










  • 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
    yesterday












  • 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
    20 hours ago


















  • 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
    yesterday










  • Do you mean the answers to both questions are no?
    – Tim
    yesterday










  • 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
    yesterday












  • 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
    20 hours ago
















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
yesterday




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
yesterday












Do you mean the answers to both questions are no?
– Tim
yesterday




Do you mean the answers to both questions are no?
– Tim
yesterday












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
yesterday






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
yesterday














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
20 hours ago




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
20 hours ago










1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer





















  • Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
    – 炸鱼薯条德里克
    23 hours ago












  • obsolete: stackoverflow.com/a/8777697/990047
    – poige
    23 hours ago











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
});


}
});














draft saved

draft discarded


















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









2














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.






share|improve this answer





















  • Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
    – 炸鱼薯条德里克
    23 hours ago












  • obsolete: stackoverflow.com/a/8777697/990047
    – poige
    23 hours ago
















2














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.






share|improve this answer





















  • Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
    – 炸鱼薯条德里克
    23 hours ago












  • obsolete: stackoverflow.com/a/8777697/990047
    – poige
    23 hours ago














2












2








2






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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









poige

4,0291543




4,0291543












  • Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
    – 炸鱼薯条德里克
    23 hours ago












  • obsolete: stackoverflow.com/a/8777697/990047
    – poige
    23 hours ago


















  • Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
    – 炸鱼薯条德里克
    23 hours ago












  • obsolete: stackoverflow.com/a/8777697/990047
    – poige
    23 hours ago
















Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
23 hours ago






Wouldn't there be a ioctl TIOCNOTTY that is able to detach session from controlling terminal?
– 炸鱼薯条德里克
23 hours ago














obsolete: stackoverflow.com/a/8777697/990047
– poige
23 hours ago




obsolete: stackoverflow.com/a/8777697/990047
– poige
23 hours ago


















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

19世紀