How to disown a process from another shellWhat is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?Difference between nohup, disown and &In zsh, how can I more quickly disown the foreground process?Disowning child from parent processIs it possible to add a process to the job list in bash (e.g. to reverse “disown”)?Is it possible to transfer a running process to your terminal?Enter process running in background/bring to foregroundany way to un-disown / re-attach an interactive process to the tty?Pass process ownership to another shellHow can I background a shell script during a Kickstart?In zsh, how can I more quickly disown the foreground process?Why the kernel kills my process with disown when I logout?automatically disown application when running it from a terminalDisowning child from parent processShould exec always be the last line of shell script?
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Banach space and Hilbert space topology
How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?
How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)
Infinite past with a beginning?
If Manufacturer spice model and Datasheet give different values which should I use?
A Journey Through Space and Time
What defenses are there against being summoned by the Gate spell?
Can I make popcorn with any corn?
What do you call a Matrix-like slowdown and camera movement effect?
What Brexit solution does the DUP want?
What are these boxed doors outside store fronts in New York?
What makes Graph invariants so useful/important?
Why is an old chain unsafe?
How is this relation reflexive?
Why is "Reports" in sentence down without "The"
I see my dog run
How old can references or sources in a thesis be?
Example of a relative pronoun
Why is the design of haulage companies so “special”?
TGV timetables / schedules?
Download, install and reboot computer at night if needed
What typically incentivizes a professor to change jobs to a lower ranking university?
Why CLRS example on residual networks does not follows its formula?
How to disown a process from another shell
What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?Difference between nohup, disown and &In zsh, how can I more quickly disown the foreground process?Disowning child from parent processIs it possible to add a process to the job list in bash (e.g. to reverse “disown”)?Is it possible to transfer a running process to your terminal?Enter process running in background/bring to foregroundany way to un-disown / re-attach an interactive process to the tty?Pass process ownership to another shellHow can I background a shell script during a Kickstart?In zsh, how can I more quickly disown the foreground process?Why the kernel kills my process with disown when I logout?automatically disown application when running it from a terminalDisowning child from parent processShould exec always be the last line of shell script?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
To avoid a process to stop when exiting the shell, you can launch the command via nohup
or screen
. It is also possible to disown an existing process with following commands:
mycommand
# Press CTRL-Z
bg
disown %1
But this can be launched only from current shell.
I'd like to do the same thing using another shell/ssh session (command launched on shell A, but disown launched on shell B).
Putting the process in background from another shell is possible:
# CTRL-Z can be done via
kill -20 PID (SIGSTP)
# bg can be done via
kill -18 PID (SIGCONT)
But the process is still owned by the initial shell. How do I disown the process from another shell?
I'm using Linux 4.15
shell terminal process disown
add a comment |
To avoid a process to stop when exiting the shell, you can launch the command via nohup
or screen
. It is also possible to disown an existing process with following commands:
mycommand
# Press CTRL-Z
bg
disown %1
But this can be launched only from current shell.
I'd like to do the same thing using another shell/ssh session (command launched on shell A, but disown launched on shell B).
Putting the process in background from another shell is possible:
# CTRL-Z can be done via
kill -20 PID (SIGSTP)
# bg can be done via
kill -18 PID (SIGCONT)
But the process is still owned by the initial shell. How do I disown the process from another shell?
I'm using Linux 4.15
shell terminal process disown
See unix.stackexchange.com/a/452267/117549
– Jeff Schaller♦
Aug 1 '18 at 13:23
@JeffSchaller : it is indeed the same issue (from a distinct perspective). Unfortunately I can't change the code of the process.
– Golgot
Aug 1 '18 at 14:12
If you hadn't twice erroneously conflated terminal and shell in the question, people would likely not be conflatingdisown
andnohup
in answers.disown
ing is a shell notion, not a terminal one. unix.stackexchange.com/questions/3886 unix.stackexchange.com/questions/4126
– JdeBP
Aug 1 '18 at 14:24
@JdeBP, You are right, I changed terminology to shell...
– Golgot
Aug 1 '18 at 14:33
You might also look at reptyr which tries to move a process to a new pty (eg terminal).
– meuh
Aug 1 '18 at 16:03
add a comment |
To avoid a process to stop when exiting the shell, you can launch the command via nohup
or screen
. It is also possible to disown an existing process with following commands:
mycommand
# Press CTRL-Z
bg
disown %1
But this can be launched only from current shell.
I'd like to do the same thing using another shell/ssh session (command launched on shell A, but disown launched on shell B).
Putting the process in background from another shell is possible:
# CTRL-Z can be done via
kill -20 PID (SIGSTP)
# bg can be done via
kill -18 PID (SIGCONT)
But the process is still owned by the initial shell. How do I disown the process from another shell?
I'm using Linux 4.15
shell terminal process disown
To avoid a process to stop when exiting the shell, you can launch the command via nohup
or screen
. It is also possible to disown an existing process with following commands:
mycommand
# Press CTRL-Z
bg
disown %1
But this can be launched only from current shell.
I'd like to do the same thing using another shell/ssh session (command launched on shell A, but disown launched on shell B).
Putting the process in background from another shell is possible:
# CTRL-Z can be done via
kill -20 PID (SIGSTP)
# bg can be done via
kill -18 PID (SIGCONT)
But the process is still owned by the initial shell. How do I disown the process from another shell?
I'm using Linux 4.15
shell terminal process disown
shell terminal process disown
edited Mar 27 at 14:51
daaawx
10312
10312
asked Aug 1 '18 at 13:11
GolgotGolgot
1165
1165
See unix.stackexchange.com/a/452267/117549
– Jeff Schaller♦
Aug 1 '18 at 13:23
@JeffSchaller : it is indeed the same issue (from a distinct perspective). Unfortunately I can't change the code of the process.
– Golgot
Aug 1 '18 at 14:12
If you hadn't twice erroneously conflated terminal and shell in the question, people would likely not be conflatingdisown
andnohup
in answers.disown
ing is a shell notion, not a terminal one. unix.stackexchange.com/questions/3886 unix.stackexchange.com/questions/4126
– JdeBP
Aug 1 '18 at 14:24
@JdeBP, You are right, I changed terminology to shell...
– Golgot
Aug 1 '18 at 14:33
You might also look at reptyr which tries to move a process to a new pty (eg terminal).
– meuh
Aug 1 '18 at 16:03
add a comment |
See unix.stackexchange.com/a/452267/117549
– Jeff Schaller♦
Aug 1 '18 at 13:23
@JeffSchaller : it is indeed the same issue (from a distinct perspective). Unfortunately I can't change the code of the process.
– Golgot
Aug 1 '18 at 14:12
If you hadn't twice erroneously conflated terminal and shell in the question, people would likely not be conflatingdisown
andnohup
in answers.disown
ing is a shell notion, not a terminal one. unix.stackexchange.com/questions/3886 unix.stackexchange.com/questions/4126
– JdeBP
Aug 1 '18 at 14:24
@JdeBP, You are right, I changed terminology to shell...
– Golgot
Aug 1 '18 at 14:33
You might also look at reptyr which tries to move a process to a new pty (eg terminal).
– meuh
Aug 1 '18 at 16:03
See unix.stackexchange.com/a/452267/117549
– Jeff Schaller♦
Aug 1 '18 at 13:23
See unix.stackexchange.com/a/452267/117549
– Jeff Schaller♦
Aug 1 '18 at 13:23
@JeffSchaller : it is indeed the same issue (from a distinct perspective). Unfortunately I can't change the code of the process.
– Golgot
Aug 1 '18 at 14:12
@JeffSchaller : it is indeed the same issue (from a distinct perspective). Unfortunately I can't change the code of the process.
– Golgot
Aug 1 '18 at 14:12
If you hadn't twice erroneously conflated terminal and shell in the question, people would likely not be conflating
disown
and nohup
in answers. disown
ing is a shell notion, not a terminal one. unix.stackexchange.com/questions/3886 unix.stackexchange.com/questions/4126– JdeBP
Aug 1 '18 at 14:24
If you hadn't twice erroneously conflated terminal and shell in the question, people would likely not be conflating
disown
and nohup
in answers. disown
ing is a shell notion, not a terminal one. unix.stackexchange.com/questions/3886 unix.stackexchange.com/questions/4126– JdeBP
Aug 1 '18 at 14:24
@JdeBP, You are right, I changed terminology to shell...
– Golgot
Aug 1 '18 at 14:33
@JdeBP, You are right, I changed terminology to shell...
– Golgot
Aug 1 '18 at 14:33
You might also look at reptyr which tries to move a process to a new pty (eg terminal).
– meuh
Aug 1 '18 at 16:03
You might also look at reptyr which tries to move a process to a new pty (eg terminal).
– meuh
Aug 1 '18 at 16:03
add a comment |
2 Answers
2
active
oldest
votes
This is not possible.
Well, it is if you are prepared to muck around with a debugger, and poke the internals of the process running your shell program. So more specifically: this is not possible in a simple straightforward manner at the level of shell programming.
This is because disown
affects a list of "jobs" that the shell program maintains in the memory space of each individual shell process.
Shells (job control ones, that is) remember the child processes that they forked in their internal "job tables", until they are instructed to forget about them by disown
or the child processes terminate and the shell has wait()
ed for them and reported the termination of the "job". disown
does not affect the child process state in any way. It affects what the shell does.
Because it forgets about the disown
ed process …
- … it no longer recognizes the completion of a "job" when
wait()
informs it about the termination of the child; - … it no longer cares if the process is still running when it is told to
exit
/logout
; and - … it no longer sends a hangup signal to the child when it receives a hangup signal itself (or, in the case of some shell programs, when it exits and it knows that it is an interactive login shell).
Shells do not share these lists, and they are not easily accessible (sans, as mentioned, firing up a debugger and attaching it) from other processes. There is no IPC mechanism or command-line tool for accessing them except for the built-in disown
command run within the relevant shell process itself. (This is why it is a built-in command.)
This is why you cannot even disown
jobs from a second shell even within the same login session. disown
is entirely a per-shell per-shell-process thing.
Furthermore …
Putting the process in background from another shell is possible.
Actually, that is not what you've been doing.
The notion of foreground and background are relative to the controlling terminal of the session. Specifically, there is one process group, known to the controlling terminal, that is the foreground process group. Stopping and continuing processes does not by itself switch processes between foreground and background. One needs to update the controlling terminal's foreground process group as well. A foreground process is only in the foreground by dint of being a member of that foreground process group. All other process groups in that session, and thus processes in those process groups, are in the background.
Ironically, you haven't been doing this from another shell. What you've been doing is triggering the original shell process to take action. It sees the main process of the foreground process group stop, and it adjusts the terminal's foreground process group (back to its own process group) in response.
The right signal is SIGTSTP
, by the way.
Further reading
- In zsh, how can I more quickly disown the foreground process?
- Is it possible to add a process to the job list in bash (e.g. to reverse "disown")?
add a comment |
If you are on Solaris, you may call:
nohup -p <pid>
This removes the current controlling terminal and connects stdout to a file in the filesystem.
To be able to do this, you need to have support from the kernel (in this case the /proc filesystem). Support to the nohup
program has been added to Solaris in 2001. If other platforms are able to attach debuggers to running processes from other terminals, this feature could be added.
BTW: If you look at the shell that was running the process before, you may see a "no children" error message from the wait() call in the shell.
I am currently not aware of similar constructs on other platforms.
Thank you for your reply, unfortunately I'm not on Solaris but it may help other people...
– Golgot
Aug 1 '18 at 14:10
This is conflatingnohup
anddisown
. The questioner is asking about the latter.
– JdeBP
Aug 1 '18 at 14:20
And since nohup does what the questioner was asking for, I created this answer. It should be obvious thatdisown
cannot do what the questioner likes to do, asdisown
just removes a job from the job table of a shell but does not have any influence on the job itself.
– schily
Aug 1 '18 at 14:35
nohup
was not what the questioner was asking for. This is pretty clear in the question, where it talks about jobs being killed by a shell when it exits, explicitly usesdisown
, explicitly distinguishes what it is talking about fromnohup
, and requests to perform the same thing asdisown
from outwith the shell.
– JdeBP
Aug 1 '18 at 14:52
Reread the question: this was on how to detach the controlling tty and this can only be done via nohup.
– schily
Aug 1 '18 at 14:54
|
show 5 more comments
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%2f459852%2fhow-to-disown-a-process-from-another-shell%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is not possible.
Well, it is if you are prepared to muck around with a debugger, and poke the internals of the process running your shell program. So more specifically: this is not possible in a simple straightforward manner at the level of shell programming.
This is because disown
affects a list of "jobs" that the shell program maintains in the memory space of each individual shell process.
Shells (job control ones, that is) remember the child processes that they forked in their internal "job tables", until they are instructed to forget about them by disown
or the child processes terminate and the shell has wait()
ed for them and reported the termination of the "job". disown
does not affect the child process state in any way. It affects what the shell does.
Because it forgets about the disown
ed process …
- … it no longer recognizes the completion of a "job" when
wait()
informs it about the termination of the child; - … it no longer cares if the process is still running when it is told to
exit
/logout
; and - … it no longer sends a hangup signal to the child when it receives a hangup signal itself (or, in the case of some shell programs, when it exits and it knows that it is an interactive login shell).
Shells do not share these lists, and they are not easily accessible (sans, as mentioned, firing up a debugger and attaching it) from other processes. There is no IPC mechanism or command-line tool for accessing them except for the built-in disown
command run within the relevant shell process itself. (This is why it is a built-in command.)
This is why you cannot even disown
jobs from a second shell even within the same login session. disown
is entirely a per-shell per-shell-process thing.
Furthermore …
Putting the process in background from another shell is possible.
Actually, that is not what you've been doing.
The notion of foreground and background are relative to the controlling terminal of the session. Specifically, there is one process group, known to the controlling terminal, that is the foreground process group. Stopping and continuing processes does not by itself switch processes between foreground and background. One needs to update the controlling terminal's foreground process group as well. A foreground process is only in the foreground by dint of being a member of that foreground process group. All other process groups in that session, and thus processes in those process groups, are in the background.
Ironically, you haven't been doing this from another shell. What you've been doing is triggering the original shell process to take action. It sees the main process of the foreground process group stop, and it adjusts the terminal's foreground process group (back to its own process group) in response.
The right signal is SIGTSTP
, by the way.
Further reading
- In zsh, how can I more quickly disown the foreground process?
- Is it possible to add a process to the job list in bash (e.g. to reverse "disown")?
add a comment |
This is not possible.
Well, it is if you are prepared to muck around with a debugger, and poke the internals of the process running your shell program. So more specifically: this is not possible in a simple straightforward manner at the level of shell programming.
This is because disown
affects a list of "jobs" that the shell program maintains in the memory space of each individual shell process.
Shells (job control ones, that is) remember the child processes that they forked in their internal "job tables", until they are instructed to forget about them by disown
or the child processes terminate and the shell has wait()
ed for them and reported the termination of the "job". disown
does not affect the child process state in any way. It affects what the shell does.
Because it forgets about the disown
ed process …
- … it no longer recognizes the completion of a "job" when
wait()
informs it about the termination of the child; - … it no longer cares if the process is still running when it is told to
exit
/logout
; and - … it no longer sends a hangup signal to the child when it receives a hangup signal itself (or, in the case of some shell programs, when it exits and it knows that it is an interactive login shell).
Shells do not share these lists, and they are not easily accessible (sans, as mentioned, firing up a debugger and attaching it) from other processes. There is no IPC mechanism or command-line tool for accessing them except for the built-in disown
command run within the relevant shell process itself. (This is why it is a built-in command.)
This is why you cannot even disown
jobs from a second shell even within the same login session. disown
is entirely a per-shell per-shell-process thing.
Furthermore …
Putting the process in background from another shell is possible.
Actually, that is not what you've been doing.
The notion of foreground and background are relative to the controlling terminal of the session. Specifically, there is one process group, known to the controlling terminal, that is the foreground process group. Stopping and continuing processes does not by itself switch processes between foreground and background. One needs to update the controlling terminal's foreground process group as well. A foreground process is only in the foreground by dint of being a member of that foreground process group. All other process groups in that session, and thus processes in those process groups, are in the background.
Ironically, you haven't been doing this from another shell. What you've been doing is triggering the original shell process to take action. It sees the main process of the foreground process group stop, and it adjusts the terminal's foreground process group (back to its own process group) in response.
The right signal is SIGTSTP
, by the way.
Further reading
- In zsh, how can I more quickly disown the foreground process?
- Is it possible to add a process to the job list in bash (e.g. to reverse "disown")?
add a comment |
This is not possible.
Well, it is if you are prepared to muck around with a debugger, and poke the internals of the process running your shell program. So more specifically: this is not possible in a simple straightforward manner at the level of shell programming.
This is because disown
affects a list of "jobs" that the shell program maintains in the memory space of each individual shell process.
Shells (job control ones, that is) remember the child processes that they forked in their internal "job tables", until they are instructed to forget about them by disown
or the child processes terminate and the shell has wait()
ed for them and reported the termination of the "job". disown
does not affect the child process state in any way. It affects what the shell does.
Because it forgets about the disown
ed process …
- … it no longer recognizes the completion of a "job" when
wait()
informs it about the termination of the child; - … it no longer cares if the process is still running when it is told to
exit
/logout
; and - … it no longer sends a hangup signal to the child when it receives a hangup signal itself (or, in the case of some shell programs, when it exits and it knows that it is an interactive login shell).
Shells do not share these lists, and they are not easily accessible (sans, as mentioned, firing up a debugger and attaching it) from other processes. There is no IPC mechanism or command-line tool for accessing them except for the built-in disown
command run within the relevant shell process itself. (This is why it is a built-in command.)
This is why you cannot even disown
jobs from a second shell even within the same login session. disown
is entirely a per-shell per-shell-process thing.
Furthermore …
Putting the process in background from another shell is possible.
Actually, that is not what you've been doing.
The notion of foreground and background are relative to the controlling terminal of the session. Specifically, there is one process group, known to the controlling terminal, that is the foreground process group. Stopping and continuing processes does not by itself switch processes between foreground and background. One needs to update the controlling terminal's foreground process group as well. A foreground process is only in the foreground by dint of being a member of that foreground process group. All other process groups in that session, and thus processes in those process groups, are in the background.
Ironically, you haven't been doing this from another shell. What you've been doing is triggering the original shell process to take action. It sees the main process of the foreground process group stop, and it adjusts the terminal's foreground process group (back to its own process group) in response.
The right signal is SIGTSTP
, by the way.
Further reading
- In zsh, how can I more quickly disown the foreground process?
- Is it possible to add a process to the job list in bash (e.g. to reverse "disown")?
This is not possible.
Well, it is if you are prepared to muck around with a debugger, and poke the internals of the process running your shell program. So more specifically: this is not possible in a simple straightforward manner at the level of shell programming.
This is because disown
affects a list of "jobs" that the shell program maintains in the memory space of each individual shell process.
Shells (job control ones, that is) remember the child processes that they forked in their internal "job tables", until they are instructed to forget about them by disown
or the child processes terminate and the shell has wait()
ed for them and reported the termination of the "job". disown
does not affect the child process state in any way. It affects what the shell does.
Because it forgets about the disown
ed process …
- … it no longer recognizes the completion of a "job" when
wait()
informs it about the termination of the child; - … it no longer cares if the process is still running when it is told to
exit
/logout
; and - … it no longer sends a hangup signal to the child when it receives a hangup signal itself (or, in the case of some shell programs, when it exits and it knows that it is an interactive login shell).
Shells do not share these lists, and they are not easily accessible (sans, as mentioned, firing up a debugger and attaching it) from other processes. There is no IPC mechanism or command-line tool for accessing them except for the built-in disown
command run within the relevant shell process itself. (This is why it is a built-in command.)
This is why you cannot even disown
jobs from a second shell even within the same login session. disown
is entirely a per-shell per-shell-process thing.
Furthermore …
Putting the process in background from another shell is possible.
Actually, that is not what you've been doing.
The notion of foreground and background are relative to the controlling terminal of the session. Specifically, there is one process group, known to the controlling terminal, that is the foreground process group. Stopping and continuing processes does not by itself switch processes between foreground and background. One needs to update the controlling terminal's foreground process group as well. A foreground process is only in the foreground by dint of being a member of that foreground process group. All other process groups in that session, and thus processes in those process groups, are in the background.
Ironically, you haven't been doing this from another shell. What you've been doing is triggering the original shell process to take action. It sees the main process of the foreground process group stop, and it adjusts the terminal's foreground process group (back to its own process group) in response.
The right signal is SIGTSTP
, by the way.
Further reading
- In zsh, how can I more quickly disown the foreground process?
- Is it possible to add a process to the job list in bash (e.g. to reverse "disown")?
edited Aug 1 '18 at 15:45
answered Aug 1 '18 at 15:39
JdeBPJdeBP
37.8k478182
37.8k478182
add a comment |
add a comment |
If you are on Solaris, you may call:
nohup -p <pid>
This removes the current controlling terminal and connects stdout to a file in the filesystem.
To be able to do this, you need to have support from the kernel (in this case the /proc filesystem). Support to the nohup
program has been added to Solaris in 2001. If other platforms are able to attach debuggers to running processes from other terminals, this feature could be added.
BTW: If you look at the shell that was running the process before, you may see a "no children" error message from the wait() call in the shell.
I am currently not aware of similar constructs on other platforms.
Thank you for your reply, unfortunately I'm not on Solaris but it may help other people...
– Golgot
Aug 1 '18 at 14:10
This is conflatingnohup
anddisown
. The questioner is asking about the latter.
– JdeBP
Aug 1 '18 at 14:20
And since nohup does what the questioner was asking for, I created this answer. It should be obvious thatdisown
cannot do what the questioner likes to do, asdisown
just removes a job from the job table of a shell but does not have any influence on the job itself.
– schily
Aug 1 '18 at 14:35
nohup
was not what the questioner was asking for. This is pretty clear in the question, where it talks about jobs being killed by a shell when it exits, explicitly usesdisown
, explicitly distinguishes what it is talking about fromnohup
, and requests to perform the same thing asdisown
from outwith the shell.
– JdeBP
Aug 1 '18 at 14:52
Reread the question: this was on how to detach the controlling tty and this can only be done via nohup.
– schily
Aug 1 '18 at 14:54
|
show 5 more comments
If you are on Solaris, you may call:
nohup -p <pid>
This removes the current controlling terminal and connects stdout to a file in the filesystem.
To be able to do this, you need to have support from the kernel (in this case the /proc filesystem). Support to the nohup
program has been added to Solaris in 2001. If other platforms are able to attach debuggers to running processes from other terminals, this feature could be added.
BTW: If you look at the shell that was running the process before, you may see a "no children" error message from the wait() call in the shell.
I am currently not aware of similar constructs on other platforms.
Thank you for your reply, unfortunately I'm not on Solaris but it may help other people...
– Golgot
Aug 1 '18 at 14:10
This is conflatingnohup
anddisown
. The questioner is asking about the latter.
– JdeBP
Aug 1 '18 at 14:20
And since nohup does what the questioner was asking for, I created this answer. It should be obvious thatdisown
cannot do what the questioner likes to do, asdisown
just removes a job from the job table of a shell but does not have any influence on the job itself.
– schily
Aug 1 '18 at 14:35
nohup
was not what the questioner was asking for. This is pretty clear in the question, where it talks about jobs being killed by a shell when it exits, explicitly usesdisown
, explicitly distinguishes what it is talking about fromnohup
, and requests to perform the same thing asdisown
from outwith the shell.
– JdeBP
Aug 1 '18 at 14:52
Reread the question: this was on how to detach the controlling tty and this can only be done via nohup.
– schily
Aug 1 '18 at 14:54
|
show 5 more comments
If you are on Solaris, you may call:
nohup -p <pid>
This removes the current controlling terminal and connects stdout to a file in the filesystem.
To be able to do this, you need to have support from the kernel (in this case the /proc filesystem). Support to the nohup
program has been added to Solaris in 2001. If other platforms are able to attach debuggers to running processes from other terminals, this feature could be added.
BTW: If you look at the shell that was running the process before, you may see a "no children" error message from the wait() call in the shell.
I am currently not aware of similar constructs on other platforms.
If you are on Solaris, you may call:
nohup -p <pid>
This removes the current controlling terminal and connects stdout to a file in the filesystem.
To be able to do this, you need to have support from the kernel (in this case the /proc filesystem). Support to the nohup
program has been added to Solaris in 2001. If other platforms are able to attach debuggers to running processes from other terminals, this feature could be added.
BTW: If you look at the shell that was running the process before, you may see a "no children" error message from the wait() call in the shell.
I am currently not aware of similar constructs on other platforms.
edited Aug 1 '18 at 14:18
answered Aug 1 '18 at 13:30
schilyschily
10.9k31744
10.9k31744
Thank you for your reply, unfortunately I'm not on Solaris but it may help other people...
– Golgot
Aug 1 '18 at 14:10
This is conflatingnohup
anddisown
. The questioner is asking about the latter.
– JdeBP
Aug 1 '18 at 14:20
And since nohup does what the questioner was asking for, I created this answer. It should be obvious thatdisown
cannot do what the questioner likes to do, asdisown
just removes a job from the job table of a shell but does not have any influence on the job itself.
– schily
Aug 1 '18 at 14:35
nohup
was not what the questioner was asking for. This is pretty clear in the question, where it talks about jobs being killed by a shell when it exits, explicitly usesdisown
, explicitly distinguishes what it is talking about fromnohup
, and requests to perform the same thing asdisown
from outwith the shell.
– JdeBP
Aug 1 '18 at 14:52
Reread the question: this was on how to detach the controlling tty and this can only be done via nohup.
– schily
Aug 1 '18 at 14:54
|
show 5 more comments
Thank you for your reply, unfortunately I'm not on Solaris but it may help other people...
– Golgot
Aug 1 '18 at 14:10
This is conflatingnohup
anddisown
. The questioner is asking about the latter.
– JdeBP
Aug 1 '18 at 14:20
And since nohup does what the questioner was asking for, I created this answer. It should be obvious thatdisown
cannot do what the questioner likes to do, asdisown
just removes a job from the job table of a shell but does not have any influence on the job itself.
– schily
Aug 1 '18 at 14:35
nohup
was not what the questioner was asking for. This is pretty clear in the question, where it talks about jobs being killed by a shell when it exits, explicitly usesdisown
, explicitly distinguishes what it is talking about fromnohup
, and requests to perform the same thing asdisown
from outwith the shell.
– JdeBP
Aug 1 '18 at 14:52
Reread the question: this was on how to detach the controlling tty and this can only be done via nohup.
– schily
Aug 1 '18 at 14:54
Thank you for your reply, unfortunately I'm not on Solaris but it may help other people...
– Golgot
Aug 1 '18 at 14:10
Thank you for your reply, unfortunately I'm not on Solaris but it may help other people...
– Golgot
Aug 1 '18 at 14:10
This is conflating
nohup
and disown
. The questioner is asking about the latter.– JdeBP
Aug 1 '18 at 14:20
This is conflating
nohup
and disown
. The questioner is asking about the latter.– JdeBP
Aug 1 '18 at 14:20
And since nohup does what the questioner was asking for, I created this answer. It should be obvious that
disown
cannot do what the questioner likes to do, as disown
just removes a job from the job table of a shell but does not have any influence on the job itself.– schily
Aug 1 '18 at 14:35
And since nohup does what the questioner was asking for, I created this answer. It should be obvious that
disown
cannot do what the questioner likes to do, as disown
just removes a job from the job table of a shell but does not have any influence on the job itself.– schily
Aug 1 '18 at 14:35
nohup
was not what the questioner was asking for. This is pretty clear in the question, where it talks about jobs being killed by a shell when it exits, explicitly uses disown
, explicitly distinguishes what it is talking about from nohup
, and requests to perform the same thing as disown
from outwith the shell.– JdeBP
Aug 1 '18 at 14:52
nohup
was not what the questioner was asking for. This is pretty clear in the question, where it talks about jobs being killed by a shell when it exits, explicitly uses disown
, explicitly distinguishes what it is talking about from nohup
, and requests to perform the same thing as disown
from outwith the shell.– JdeBP
Aug 1 '18 at 14:52
Reread the question: this was on how to detach the controlling tty and this can only be done via nohup.
– schily
Aug 1 '18 at 14:54
Reread the question: this was on how to detach the controlling tty and this can only be done via nohup.
– schily
Aug 1 '18 at 14:54
|
show 5 more comments
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%2f459852%2fhow-to-disown-a-process-from-another-shell%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
-disown, process, shell, terminal
See unix.stackexchange.com/a/452267/117549
– Jeff Schaller♦
Aug 1 '18 at 13:23
@JeffSchaller : it is indeed the same issue (from a distinct perspective). Unfortunately I can't change the code of the process.
– Golgot
Aug 1 '18 at 14:12
If you hadn't twice erroneously conflated terminal and shell in the question, people would likely not be conflating
disown
andnohup
in answers.disown
ing is a shell notion, not a terminal one. unix.stackexchange.com/questions/3886 unix.stackexchange.com/questions/4126– JdeBP
Aug 1 '18 at 14:24
@JdeBP, You are right, I changed terminology to shell...
– Golgot
Aug 1 '18 at 14:33
You might also look at reptyr which tries to move a process to a new pty (eg terminal).
– meuh
Aug 1 '18 at 16:03