Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I know whether bash kill will use a pid or a jobspec?

From the fine manual page:

kill [-s sigspec | -n signum | -sigspec] [pid | jobspec] ...
kill -l [sigspec | exit_status]
    Send  the  signal  named  by sigspec or signum to the processes named by pid or 
    jobspec.  sigspec is etc. etc....

So what decides whether kill 1 kills the init process or jobspec 1?

like image 598
einpoklum Avatar asked Feb 14 '13 08:02

einpoklum


People also ask

What does kill do in Bash?

On Unix-like operating systems, kill is a builtin command of the Bash shell. It sends a signal to a process. This page covers the bash builtin version of kill, which is distinct from the standalone binary executable, /bin/kill. To figure out which of these is the default kill on your system, run type kill.

What is a Jobspec Linux?

A job specification or "jobspec" is a way of referring to the processes that make up a job. A jobspec may be: %n to refer to job number n . %str to refer to a job which was started by a command beginning with str . It is an error if there is more than one such job.

How do I kill a bash script?

We can use “ps augx” to list all processes and the locate those with keyword by using “grep keyword” command. Next, we need to split each line by whitespace delimiter and list the second column which is the process ID. Finally, we feed into xargs command to kill them.


1 Answers

with kill 1 you will send a signal to process with pid 1. To kill job 1 you have to type

  kill %1

the jobspec is %

like image 57
kofemann Avatar answered Nov 04 '22 23:11

kofemann