3
votes
5answers
689 views

Getting pid of bash script from itself

I have a bash script with doing lot of things called script.sh: #!/bin/bash #It #Is #Doing #Things Is there a way that I be able to get the proccess of script and then kill it after 5 minutes? ...
2
votes
2answers
128 views

Bash script to signal a concurrently running instance (same script) about a condition and increment counter

Background Here's what I want to achieve. I have a (potentially) long-running process. Now I have locking in place just fine and all is generally in order. However, since this is a scheduled job, ...
5
votes
2answers
288 views

Processes do not respond to my signals

I have a strange behavior on my system. When I invoke a command in the shell (bash version 4.2.45(1)-release), say top or cat, the running program (the process) does not respond to Ctrl+C. I even ...
34
votes
6answers
4k views

Does pressing ctrl-c several times make the running program close more quickly?

I often start to read a huge file and then want to quit after a while, but there is a lag from pressing Ctrl+C to the program stops. Is there a chance of shortening the lag by pressing the Ctrl+C key ...
0
votes
2answers
160 views

What does this logrotate nginx config do?

In my /etc/logrotate.d/nginx I saw, /var/log/nginx/*.log { daily missingok rotate 52 compress delaycompress notifempty create 640 nginx adm ...
9
votes
3answers
3k views

Default exit code when process is terminated?

When a process is killed with a handle-able signal like SIGINT or SIGTERM but it does not handle the signal, what will be the exit code of the process? What about for unhandle-able signals like ...
1
vote
1answer
92 views

How to list killable tasks?

As manpage of ps states A process with STATUS with the value "D" means "uninterruptible sleep (usually IO)" Also, I've read: You should use TASK_INTERRUPTIBLE here, otherwise your kernel thread ...
7
votes
1answer
348 views

How signals work internally?

In general, to kill processes we generate signals like SIGKILL,SIGTSTP etc. But how is it known who ordered that particular signal, who has sent it to a particular process, and in general how do ...
6
votes
2answers
209 views

Decode Flags for Kill Command

I am new to Shell Scripting. I saw this Command on a Book for Linux shell Scripting $ kill -HUP 1234 >killout.txt 2>killerr.txt I know what the command does, but i am not able to understand ...
2
votes
2answers
370 views

Why is `kill -s INT <zsh PID>` behaving differently from `Ctrl-C`?

Starting with: % donothing () { echo $$; sleep 1000000 } % donothing 47139 If at this point I hit Ctrl-C at the same terminal that is controlling the shell, then the function donothing does indeed ...
2
votes
1answer
101 views

Chain commands with Control + C interrupt

I am trying to execute a program which loops indefinitely, and so must be forcibly interrupted. After executing the program, I want to delete it. I can do it in several steps: ./MyProg Control + C ...
19
votes
1answer
1k views

How does systemd survive a kill -9?

Between the recent "Why does 'kill -9 0' end my console session" and "How to get a kernel panic" questions, I got a bur under my saddle and tried kill -9 1 on a mostly up-to-date Arch linux laptop. I ...
4
votes
1answer
526 views

What is the difference between exiting a process via Ctrl+C vs issuing a kill -9 command?

I know I can kill any process with kill -9 command . But sometimes i see that even if I have terminated a program with CTRL+C , the process doesn't get killed . So I want to know the difference ...
6
votes
1answer
592 views

`kill -s TERM` works, `kill -s ABRT` gets “Operation not permitted”

There is a process that I own whose documentation claims I can send SIGABRT to in order to get some debugging information. However, when I try to send SIGABRT, I get back "Operation not permitted". I ...
2
votes
2answers
736 views

Why can't I kill a timeout called from a Bash script with a keystroke?

[Edit: This looks similar to some other questions asking how to kill all spawned processes – the answers all seem to be to use pkill. So the core of my question may be: Is there a way to propagate ...
9
votes
4answers
4k views

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I Ctrlc the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It ...
11
votes
3answers
764 views

How Can Terminal Emulators Kill Their Children After Recieving a SIGKILL?

From what I understand, SIGKILL cannot be caught. This would imply that a process does not have time to kill it's children before the OS destroys it. This can be demonstrated with a shell script. ...
3
votes
2answers
2k views

Why would Ctrl-C behave differently than kill -2

I have a program which is supposed to handle SIGINT and gracefully shut down. When I run this program from a terminal without backgrounding it I can shut it down just fine using Ctrl-C. Inspecting the ...
9
votes
4answers
3k views

How to make `xargs` ignore child's exit and keep processing further

I sometimes run long xargs jobs overnight and it is really annoying to discover in the morning that xargs died somewhere in the middle, for example because of a segmentation fault in one single ...
3
votes
3answers
903 views

Killing other user processes

There are certain user environments in which we have to login during certain performance testing and and kill all the process running in that environment. The environment names are like rswrk01, … up ...
21
votes
2answers
572 views

When you try to terminate a process for good, which option for “kill” should you use?

I am getting a lot of mixed messages from people, and was wondering if it there really is not much of a difference in what you use. kill 'x' killall 'x' kill -9 'x' These are some options I've been ...
10
votes
5answers
3k views

How to soft kill gui applications via terminal?

Is there a way to close a GUI application in friendly "please quit yourself now" way, without graphical access to the applications window? For example, if Gnome/X display crashes to black, I'd like ...
20
votes
2answers
2k views

why would typing Ctrl+c twice stop a running process in Linux?

There are Linux programs, for example vlc, that recommend typing ctrl+c twice to kill their execution from a terminal if the program didn't stop after the first one. Why would typing ctrl+c twice ...
6
votes
2answers
7k views

Program behavior when kill -HUP is recieved?

Is there a way to find out what will program do when it receives kill signal HUP? Without simply running the command ofc :D For example, killall -HUP pppd will restart pppd killall -HUP firefox ...
13
votes
2answers
19k views

How can I kill a <defunct> process whose parent is init?

Transmission is intermittently hanging on my NAS. If I send SIGTERM, it doesn't disappear from the process list and a <defunct> label appears next to it. If I send a SIGKILL, it still doesn't ...