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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












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















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













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

















  • 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
















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










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?

    – 炸鱼薯条德里克
    Jan 4 at 6:13












  • obsolete: stackoverflow.com/a/8777697/990047

    – poige
    Jan 4 at 6:21










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?

    – 炸鱼薯条德里克
    Jan 4 at 6:13












  • obsolete: stackoverflow.com/a/8777697/990047

    – poige
    Jan 4 at 6:21















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?

    – 炸鱼薯条德里克
    Jan 4 at 6:13












  • obsolete: stackoverflow.com/a/8777697/990047

    – poige
    Jan 4 at 6:21













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

















  • 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

















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.




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 check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay