1. 9
  1.  

  2. 3

    On an illumos system, you can use the libproc(3LIB) interfaces to achieve a similar thing without the use of a debugger. It would be reasonably easy to make a kind of custom splicing tool which could replace any open fd with an fd for a different path.

    The rough sequence would be a call to Pgrab(3PROC) followed by a call to pr_open(3PROC) to open the new file descriptor in the target process. Once you have a file descriptor, you can use pr_fcntl(3PROC) to simulate dup(2) using the F_DUP2FD argument (described in fcntl(2)). Finally, use Prelease(3PROC) to let go of the target process and set it running again.

    Our nohup(1) also includes a -p flag which allows the user to apply the semantics of nohup after the fact, rather than needing to do it in advance when starting the process – including redirecting any subsequent output that would have gone to the controlling terminal to the nohup.out file. This is done with a similar sequence of calls to those I briefly described above.