process - What happens in BASH when you do Ctrl-C (hint, it's not simply sending a SIGINT) -



process - What happens in BASH when you do Ctrl-C (hint, it's not simply sending a SIGINT) -

a little background first - when apt-get install downloads company net provides high burst of speed (400-500kb/s) first 10 seconds or before dropping downwards 10th of (40-50kb/s), , after few minutes miserable (4-5kb/s). makes me think sysadmin has implemented sort of network throttling scheme.

now know network not erratic, because if start apt-get install foo, ctrl-c after 10 seconds , run apt-get install foo 1 time again (by doing arrow , come in utilize bash history), , keep repeating process few minutes till packages downloaded, can download big packages fast. in particular, after aborting download ctrl-c, apt-get seems able resume download in next invocation.

of course, staring @ screen doing ctrl-c come in every 10 seconds gets boring real fast, wrote shell script -

#!/bin/sh in `seq 1 100` ; sudo apt-get install foo -y & sleep 10 sudo kill -2 $! done

this seems work. spawns apt-get, runs 10 seconds , kills (by sending sigint) , starts again. however, doesn't work because apt-get not resume downloads on subsequent invocations!

an experiment ran sudo apt-get install foo 1 terminal , ran kill -2 <pid of apt-get> terminal. , in case, when restart apt-get, not resume download.

so ctrl-c not equivalent sigint. , else happening when ctrl-c manually gives apt-get chance save state of download. question - it?

edit

these suggestions have received far, no cigars. mystery deepens! -

on sudo kill -2 $! signal might going sudo instead of apt-get. not reason because mentioned above tried sending sigint apt-get's pid , prevented apt-get saving state.

sudo catches signal , sends other signal apt-get. tried sending apt-get signals can think of! still not resume download of them. resumes downloads when ctrl-c kill it.

apt-get handles sigint differently if script instead of interactive shell. again, "experiment" above proves not true.

hint, it's not sending sigint).

yes sending sigint :-) throttling happening, you've got right. here's suspect happening:

something limiting bandwidth of conections. track connections it's including source port (which bad thought imo) among other parameters

when kill apt-get , restart it, naturally new tcp source port , evil entity throttling think, "oh, it's new connection", is

so how speed things ? real solution utilize multiple parallel downloads. never used myself, have heard of tool called "apt-fast" (actually bash script itself) this.

edit

after reading question 1 time again suspect signal not sent apt-get.

sudo apt-get install foo -y & sudo kill -2 $! # sends signal sudo, sends whatever wants `apt-get`

so believe sudo catches signal , sends else (sigterm? sighup?) apt-get.

bash process kill apt sigint

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -