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 by bg)get its pid (jobs -p %+ to get its <pid>)open a screen or tmux session, attach to it and use it for the following stepsuse 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...
Is it possible to add a process to the job list in bash (e.g. to reverse disown)?
bash;process;jobs;disown;reptyr
In general, it isn't possible for a shell to adopt a job. For a shell, a job means a few things:Associate a job identifier with a process ID.Display its status (running, suspended, dead).Notify the user when the status changes.Send a SIGHUP signal when the terminal goes away.Control whether the job owns the terminal (whether it's the foreground process group).Most of these don't require any special association between the shell and the job, but there are a few that do:In order to notify the user when the status changes, the shell relies on receiving a SIGCLD signal. This signal is sent by the kernel to the parent process of the job's initial process.In order to control access to the terminal, the shell needs to be in the same session as the job.It isn't possible for a process to adopt another process, nor to attach a process to an existing session. So in order to support adoption, the shell would have to manage a partial status. The usual shells haven't implemented this.In the special case where the job is one that was initially started by that shell and then disowned, these problems do not arise. But none of the usual shells have implemented an exception to the exception that lets them add a job if they had initially started it.In your scenario, it would usually be most convenient to start the job in a screen or tmux session, and to use the PID if you want to suspend or resume it.