Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View output of process redirected to dev/null - undo redirection

I've pushed a couple of process to background and redirected the output to /dev/null. I want undo that and see what's happening since its been in the background for a long time.

Is there a way to undo the > /dev/null redirection and bring the process to foreground?

like image 676
user630702 Avatar asked Feb 13 '26 02:02

user630702


1 Answers

I think you question would be better posted on unix.

There, you can find How to change the output redirection of a running process?, which exactly your question casted in a more general form.

From the answers, and from the 3rd party tool (redirect) suggested in the accepted answer by its creator, which is mostly written in C, I deduce that there's no shell-only way to accomplish what you want.

However that question is from 2012, so you might want to ask a new one to see if something changed in the meanwhile.

Last but not least, doing some search in man bash I've found the Coprocesses section, that reads

[…] A coprocess is executed asynchronously in a subshell, as if the command had been
terminated with the & control operator, with a two-way pipe established between
the executing shell and the coprocess. […] The standard output of command is
connected via a pipe to a file descriptor in the executing shell, and that
file descriptor is assigned to NAME[0]. The standard input […]

which is probably a way to launch processes in background without losing the ability to change their file descriptors, if I interpret the quote correctly.

like image 141
Enlico Avatar answered Feb 15 '26 21:02

Enlico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!