For a non-controlling process, is `ioctl(fd, TIOCNOTTY)` the same as `close(fd)`?
Assume a session has a controlling terminal.
If a process in the session that is not the session leader, calls ioctl(fd, TIOCNOTTY)
, is it correct that it only closes the fd
for itself? Is it the same as close(fd)
?
Thanks.
linux controlling-terminal
|
show 6 more comments
Assume a session has a controlling terminal.
If a process in the session that is not the session leader, calls ioctl(fd, TIOCNOTTY)
, is it correct that it only closes the fd
for itself? Is it the same as close(fd)
?
Thanks.
linux controlling-terminal
1
This question takes as a premise the false notion that terminals have controlling processes, and is thus unanswerable. Terminals have foreground process groups, and sessions have controlling terminals. The general notion of a controlling process for a terminal does not exist.
– JdeBP
yesterday
man7.org/linux/man-pages/man4/tty.4.html might help - look at "If the process is the session leader ..."
– Mark Plotnick
yesterday
@JdeBP from the susv4_exit
: "If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.".
– mosvy
yesterday
@JdeBP and here is the definition. Notice that a controlling process is always a session leader, but not vice-versa.
– mosvy
yesterday
1
@Tim why do you think thatioctl(fd, TIOCNOTTY)
is closing that fd? It isn't.echo 'int main(void){ ioctl(1, TIOCNOTTY); write(1, "foon", 4); }' | cc -include sys/ioctl.h -include unistd.h -Wall -x c - && ./a.out
– mosvy
yesterday
|
show 6 more comments
Assume a session has a controlling terminal.
If a process in the session that is not the session leader, calls ioctl(fd, TIOCNOTTY)
, is it correct that it only closes the fd
for itself? Is it the same as close(fd)
?
Thanks.
linux controlling-terminal
Assume a session has a controlling terminal.
If a process in the session that is not the session leader, calls ioctl(fd, TIOCNOTTY)
, is it correct that it only closes the fd
for itself? Is it the same as close(fd)
?
Thanks.
linux controlling-terminal
linux controlling-terminal
edited yesterday
炸鱼薯条德里克
423114
423114
asked yesterday
Tim
26.2k74246455
26.2k74246455
1
This question takes as a premise the false notion that terminals have controlling processes, and is thus unanswerable. Terminals have foreground process groups, and sessions have controlling terminals. The general notion of a controlling process for a terminal does not exist.
– JdeBP
yesterday
man7.org/linux/man-pages/man4/tty.4.html might help - look at "If the process is the session leader ..."
– Mark Plotnick
yesterday
@JdeBP from the susv4_exit
: "If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.".
– mosvy
yesterday
@JdeBP and here is the definition. Notice that a controlling process is always a session leader, but not vice-versa.
– mosvy
yesterday
1
@Tim why do you think thatioctl(fd, TIOCNOTTY)
is closing that fd? It isn't.echo 'int main(void){ ioctl(1, TIOCNOTTY); write(1, "foon", 4); }' | cc -include sys/ioctl.h -include unistd.h -Wall -x c - && ./a.out
– mosvy
yesterday
|
show 6 more comments
1
This question takes as a premise the false notion that terminals have controlling processes, and is thus unanswerable. Terminals have foreground process groups, and sessions have controlling terminals. The general notion of a controlling process for a terminal does not exist.
– JdeBP
yesterday
man7.org/linux/man-pages/man4/tty.4.html might help - look at "If the process is the session leader ..."
– Mark Plotnick
yesterday
@JdeBP from the susv4_exit
: "If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.".
– mosvy
yesterday
@JdeBP and here is the definition. Notice that a controlling process is always a session leader, but not vice-versa.
– mosvy
yesterday
1
@Tim why do you think thatioctl(fd, TIOCNOTTY)
is closing that fd? It isn't.echo 'int main(void){ ioctl(1, TIOCNOTTY); write(1, "foon", 4); }' | cc -include sys/ioctl.h -include unistd.h -Wall -x c - && ./a.out
– mosvy
yesterday
1
1
This question takes as a premise the false notion that terminals have controlling processes, and is thus unanswerable. Terminals have foreground process groups, and sessions have controlling terminals. The general notion of a controlling process for a terminal does not exist.
– JdeBP
yesterday
This question takes as a premise the false notion that terminals have controlling processes, and is thus unanswerable. Terminals have foreground process groups, and sessions have controlling terminals. The general notion of a controlling process for a terminal does not exist.
– JdeBP
yesterday
man7.org/linux/man-pages/man4/tty.4.html might help - look at "If the process is the session leader ..."
– Mark Plotnick
yesterday
man7.org/linux/man-pages/man4/tty.4.html might help - look at "If the process is the session leader ..."
– Mark Plotnick
yesterday
@JdeBP from the susv4
_exit
: "If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.".– mosvy
yesterday
@JdeBP from the susv4
_exit
: "If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.".– mosvy
yesterday
@JdeBP and here is the definition. Notice that a controlling process is always a session leader, but not vice-versa.
– mosvy
yesterday
@JdeBP and here is the definition. Notice that a controlling process is always a session leader, but not vice-versa.
– mosvy
yesterday
1
1
@Tim why do you think that
ioctl(fd, TIOCNOTTY)
is closing that fd? It isn't. echo 'int main(void){ ioctl(1, TIOCNOTTY); write(1, "foon", 4); }' | cc -include sys/ioctl.h -include unistd.h -Wall -x c - && ./a.out
– mosvy
yesterday
@Tim why do you think that
ioctl(fd, TIOCNOTTY)
is closing that fd? It isn't. echo 'int main(void){ ioctl(1, TIOCNOTTY); write(1, "foon", 4); }' | cc -include sys/ioctl.h -include unistd.h -Wall -x c - && ./a.out
– mosvy
yesterday
|
show 6 more comments
0
active
oldest
votes
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%2f492531%2ffor-a-non-controlling-process-is-ioctlfd-tiocnotty-the-same-as-closefd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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%2f492531%2ffor-a-non-controlling-process-is-ioctlfd-tiocnotty-the-same-as-closefd%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
1
This question takes as a premise the false notion that terminals have controlling processes, and is thus unanswerable. Terminals have foreground process groups, and sessions have controlling terminals. The general notion of a controlling process for a terminal does not exist.
– JdeBP
yesterday
man7.org/linux/man-pages/man4/tty.4.html might help - look at "If the process is the session leader ..."
– Mark Plotnick
yesterday
@JdeBP from the susv4
_exit
: "If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.".– mosvy
yesterday
@JdeBP and here is the definition. Notice that a controlling process is always a session leader, but not vice-versa.
– mosvy
yesterday
1
@Tim why do you think that
ioctl(fd, TIOCNOTTY)
is closing that fd? It isn't.echo 'int main(void){ ioctl(1, TIOCNOTTY); write(1, "foon", 4); }' | cc -include sys/ioctl.h -include unistd.h -Wall -x c - && ./a.out
– mosvy
yesterday