[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to forcibly abort a command in a terminal window?



On Mon, 5 Sep 2016 17:19:38 +0200
Nicolas George <george@nsup.org> wrote:

>Le decadi 20 fructidor, an CCXXIV, Charlie Kravetz a écrit :
>> I open a second terminal, then use ps -A to find the command. I can
>> kill it with "sudo kill ????" which kills the job number. It is not
>> always instant, but faster than ctrl-c for some things, including rsync
>> and cp .  
>
>Not true.
>
>The only difference between your method and kill is that kill will send
>SIGTERM (number 15) by default while Ctrl-C sends SIGINT (number 3) by
>default. But both have the same default action of interrupting the process.
>
>cp does not handle signals explicitly, leaving them to their default
>behaviour. rsync catches signals, but with the same handler for SIGINT and
>SIGTERM. Therefore, the effect of Ctrl-C and kill on both is exactly the
>same. The difference you observe is certainly only psychological.
>
>Note that the same does not apply to "kill -9": SIGKILL, number 9, can not
>be caught by processes. Yet, since cp does not catch signals, Ctrl-C, kill
>or kill -9 will have the same effect. On rsync, "kill -9" will prevent it
>from cleaning up temp files, which can be a life saver if you forgot the -P
>option and already copied a big chunk of data over a slow link.
>
>Also note that other applications may behave differently. I have noticed
>that Python applications using Qt ignore SIGINT for no apparent reason
>except annoy developers. Knowing ^\, i.e. SIGQUIT, is useful in that kind of
>cases, even though this is not the purpose of SIGQUIT.
>
>Regards,
>

Psychological or not, it certainly works for me. By killing the job
number, it forces it to stop on my computer. 

-- 
Charlie Kravetz
Linux Registered User Number 425914
[http://linuxcounter.net/user/425914.html]
Never let anyone steal your DREAM.   [http://keepingdreams.com]


Reply to: