Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
wget and ssh session termination

If you SSH into your server and issue wget command to get file for instance, then your SSH disconnects your wget will continue its job in background. Some one might say why should it continues and how could it be when connectin of my terminal went away!?


This is from src/main.c of the wget sources (version 1.19.2):

/* Hangup signal handler.  When wget receives SIGHUP or SIGUSR1, it
will proceed operation as usual, trying to write into a log file.
If that is impossible, the output will be turned off. */


A bit further down, the signal handler is installed:

/* Setup the signal handler to redirect output when hangup is
received. */
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
signal(SIGHUP, redirect_output_signal);

So it looks like wget is not ignoring the HUP signal, but it chooses to continue processing with its output redirected to the log file.


Source code of wget main.c: http://bzr.savannah.gnu.org/lh/wget/trunk/annotate/head:/src/main.c

#linux #ssh #wget #SIGHUP #SIG_IGN #SIGUSR1