Why does `kill %jobnumber` not work on stopped jobs?

Sollosa

I'm running a few tasks side by side on an Ubuntu 18 LTS system. So I'm switching between these jobs by running:

# command &
# fg
# fg -

I'm also using Ctrl+Z sometimes to send a running job to the background.

Say I have 3 jobs in my list:

# jobs
[1]+  Stopped                 nano /etc/nginx/site-available/blog.conf
[2]   Stopped                 top
[3]-  Stopped                 nano script.sh

I can successfully switch between these, but when I run the kill command on these, the jobs still show in the list. None gets killed. Why?

# kill %1

I list again, and the jobs are still there:

# jobs
[1]+  Stopped                 nano /etc/nginx/site-available/blog.conf
[2]   Stopped                 top
[3]-  Stopped                 nano script.sh

PS: I can kill jobs with their process IDs, but why not with kill %1?

Gryu

If you could not kill process by its PID, then you could not kill it using its job's identifier.

To kill process using its job's identifier without saving data, closing session operations and so on, use:

kill -9 %1

kill sends signal number 15 (SIGTERM) to process, which could be ignored by process as it is in our case, because of it is stopped and, maybe, rejects to listen SIGTERM in stopped state. But signal number 9 (SIGKILL) is sent by kernel and it does not care if process could hear or not. It just ends it forcefully.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why kill -9 -1 doesn't work?

分類Dev

Printer jobs can not be stopped

分類Dev

console kill command does not work on Ubuntu

分類Dev

Why does kill -9 0 on a mac simply kill the bash shell?

分類Dev

why does innerHTML not work?

分類Dev

Why this kill doesn't work in this Bash script but only outside of the script?

分類Dev

Why does atq not list jobs in either queue order, or chronological order?

分類Dev

Why does this Firebase ".indexOn" not work?

分類Dev

Why does not it work async pipe?

分類Dev

Why does Horspool not work on binaries?

分類Dev

why does this negative lookahead not work?

分類Dev

Why does sudo not work with curl?

分類Dev

Why source maps does not work?

分類Dev

why does a constructor work this way?

分類Dev

Why does this rename operation not work?

分類Dev

Why does this piece of Golang code not work?

分類Dev

Why does this backreference not work inside a lookbehind?

分類Dev

Why does :host(:hover) not work here?

分類Dev

Why does the code . shortcut not work on OSX?

分類Dev

Why does #[derive(Show)] not work anymore?

分類Dev

Why my implicit function parameter does not work?

分類Dev

Why does a deserialized TDictionary not work correctly?

分類Dev

Why does a deserialized TDictionary not work correctly?

分類Dev

Why does zipWith.zipWith work?

分類Dev

Why does the break statement not work here?

分類Dev

Why git alias with push does not work?

分類Dev

why does css cursor not work for styled scrollbar

分類Dev

Why does my method for collision detection not work?

分類Dev

Why does sorting a JS array of numbers with < work?