If I disown
a job in bash
and change my mind, can I undo it somehow ?
If so, taking it further, is it possible to bring an arbitrary process under job control (an acceptable restriction would be that I own the process) ?
And, finally, would this make the below workflow possible:
- put job in background (
^z
followed bybg
) - get its pid (
jobs -p %+
to get its<pid>
) - open a
screen
ortmux
session, attach to it and use it for the following steps - use
reptyr
to grab the job (reptyr <pid>
) - add
<pid>
to shell's job control (is this possible at all?) - stop the job (
^Z
)
I can do everything except the last two steps. Stopping the job with ^Z
doesn't work because the process isn't in the shell's job list.
My research indicates that it isn't possible to own (reverse of disown
) a pid but hopefully I am wrong...
SIGSTOP
signal viakill
command. – jimmij Jul 13 '15 at 09:56bg
to place a job into the background shall cause its process ID to become "known in the current shell execution environment", as if it had been started as an asynchronous list; see Asynchronous Lists. But, anyway, if you're going this far, and since you seem to be primarily linux focused, you should probably just be working w/ namespaces. – mikeserv Jul 13 '15 at 10:01^Z
was just an example of something that isn't possible without it being owned by the shell. I don't think your comment adds any value to the question. – starfry Jul 14 '15 at 08:03reptyr -T
will steal a terminal emulator's master fd and open its own session for it. If your process and the shell process which accompanies it are associated with the same master fd - even if you have previously disowned the process you're talking about - then you may be able to reassociate the two in the newreptyr
session. – mikeserv Jul 14 '15 at 19:51