Could someone tell me why I am unable to kill the jobs below when specifying their PID? I can stop the jobs when using their % id.

Mac:~ gd$ ps


4523 ttys000 0:00.02 -bash

4560 ttys000 0:00.00 gpg

4609 ttys000 0:00.00 gpg

Mac:~ gd$ kill 4560

Mac:~ gd$ kill 4609

Mac:~ gd$ exit


There are stopped jobs.

Mac:~ g$ jobs

[1]- Stopped gpg

[2]+ Stopped gpg

Mac:~ gd$ kill %1

gpg: signal Terminated caught ... exiting


Because kill %n will run the shell builtin, which will make sure stopped jobs are sent SIGCONT so that they can realize they've been killed.

To achieve that with PIDs of stopped jobs, you need to:

kill $pid 

(Or kill -TERM $pid if you want to make it explicit)

and then

kill -CONT $pid 

You don't need the -CONT if you go for the ultimate murder weapon:

kill -KILL $pid
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.