A signal is a message which can be sent to a running process. Signals can be initiated by programs, users, or administrators.

learn more… | top users | synonyms

34
votes
2answers
1k views

How can I check what signals a process is listening to?

How can I verify whether a running process will catch a signal, or ignore it, or block it? Ideally I'd like to see a list of signals, or at least not have to actually send the signal to check.
33
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 ...
31
votes
5answers
5k views

Timing out in a shell script

I have a shell script that's reading from standard input. In rare circumstances, there will be no one ready to provide input, and the script must time out. In case of timeout, the script must execute ...
21
votes
2answers
557 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 ...
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 ...
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 ...
13
votes
2answers
18k 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 ...
12
votes
2answers
888 views

Equivalent of “truss -T” and “truss -U” on Linux?

Is there an equivalent of what the -T and -U option of the truss Solaris utility does on Linux. Those are to specify a system call (-T) or library function (-U) which when called by the traced ...
11
votes
2answers
552 views

How to terminate remotely called “tail -f” when connection is closed?

I just noticed that if I execute ssh user@remote_host tail -f /some/file , then tail -f /some/file keeps running on the remote_host even if ssh connection is closed! So, after several connects and ...
11
votes
3answers
732 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. ...
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 ...
10
votes
1answer
5k views

How to suspend and resume processes like bash does

this question is a follow-up to: How to suspend and resume processes I have started firefox from a bash session in gnome-terminal. The process tree looks like this: $ ps -e -o pid,ppid,cmd -H 1828 ...
10
votes
3answers
5k views

Telnet send Ctrl-C

I use telnet to connect to a terminal server, which proxies the traffic to a RS-232 port. Unfortunately when using some of the devices it is not possible to send the CTRL+C character (0x03). Instead ...
10
votes
2answers
111 views

Cancel completion, but only completion, in zsh

When a completion function takes a long time, I can interrupt it by pressing Ctrl+C (terminal interrupt key, sends SIGINT) or Ctrl+G (bound to send-break). I am then left with the uncompleted word. ...
9
votes
2answers
9k views

How to signal the end of stdin input in bash

In Bash, I learned that the ending signal can be changed by here document. But by default how can I signal the end of stdin input? I happened to find that with cat and chardet, their stdin inputs can ...
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 ...
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 ...
9
votes
2answers
2k views

Interruption of system calls when a signal is caught

From reading the man pages on the read() and write() calls it appears that these calls get interrupted by signals regardless of whether they have to block or not. In particular, assume a process ...
8
votes
5answers
13k views

How to stop the loop bash script in terminal?

For example, #!/bin/bash while : do sl done How to terminate this bash script?
8
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 ...
7
votes
6answers
6k views

Terminating an infinite loop

I have a command that I want to have run again automatically each time it terminates, so I ran something like this: while [ 1 ]; do COMMAND; done; but if I can't stop the loop with Ctrl-c as that ...
7
votes
2answers
2k views

What causes various signals to be sent?

I sometimes get a little confused by all of the signals that an application can receive. As I understand it, an application has a default handler for each of these signals, but it can provide its own ...
7
votes
1answer
6k views

Why does SIGUSR1 cause process to be terminated?

I was surprised with this comment in other question: Sending dd the USR1 signal too soon after it has started (i.e. in a bash script, the line after you started it) will in fact terminate it Can ...
7
votes
1answer
1k views

confirmed exit using trap

I am trying to trap the Ctrl+C signal asking a confirmation from the user. The trapping part works fine. But once the signal gets trapped, it does not return to the normal execution. Instead, it quits ...
7
votes
1answer
298 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 ...
7
votes
1answer
677 views

In which cases is SIGHUP not sent to a job when you log out?

I read an answer from a user who claimed that running foo 2>&1 >& output.log & would result in foo continuing to run even when they log out. According to this user, this even ...
7
votes
1answer
2k views

“trap … INT TERM EXIT” really necessary?

Many examples for trap use trap ... INT TERM EXIT for cleanup tasks. But is it really necessary to list all the three sigspecs? The manual says: If a SIGNAL_SPEC is EXIT (0) ARG is executed on ...
7
votes
1answer
123 views

stderr over ssh -t

This sends output to STDERR, but does not propagate Ctrl+C (i.e. Ctrl+C will kill ssh but not the remote sleep): $ ssh localhost 'sleep 100;echo foo ">&2"' This propagates Ctrl+C (i.e. ...
7
votes
1answer
241 views

What should interactive shells do in orphaned process groups?

(Re-posting in unix per the suggestion in http://stackoverflow.com/questions/13718394/what-should-interactive-shells-do-in-orphaned-process-groups) The short question is, what should a shell do if it ...
6
votes
2answers
6k 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 ...
6
votes
3answers
2k views

What's the difference between Ctrl-Z and kill -STOP?

When I run a command (make on a large project) from the shell, I can type Ctrl-Z to stop the process and return to the shell. Subsequently, I can run fg to continue the process. I'm trying to write a ...
6
votes
2answers
201 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 ...
6
votes
1answer
576 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 ...
6
votes
2answers
2k views

Get ssh to forward signals

I want to be able to send signals (SIGINT is the most important) through ssh. This command: ssh server "sleep 1000;echo f" > foo will start sleep on server and after 1000 seconds it will put ...
6
votes
1answer
313 views

SSH session pauses mid datastream; resumes with a keypress

I've had this problem occur at random, intermittently, across boxes at multiple companies, multiple distros, and multiple kernel revs. I think that I'm just cursed. What happens is that I'll have a ...
5
votes
2answers
1k views

Why does Subversion give a broken pipe error when piped into head?

If I do a svn log | head after the tenth line of output I get an error message: svn: Write error: Broken pipe What's going on here? I haven't seen any other command do this when used with head. ...
5
votes
2answers
245 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 ...
5
votes
1answer
80 views

Do not set $? to non-zero on Control+C

My $PS1 in Zsh includes this expression: %(?. %?.) It means «if exit code of previous command ($?) is true, show $?, else show nothing». This is generally useful, but one thing annoys me: shells set ...
5
votes
1answer
36 views

Ctrl-C is ignored by pppd when put in a shell script

I'm trying to connect to GPRS network through a serial port connected GSM modem. When I call /usr/sbin/pppd call <peer_name> from the command line, it correctly receives and handles Ctrl+C from ...
4
votes
3answers
323 views

What documentation shows the associated numbers for linux signals like SIGTERM and SIGKILL?

I can look around the internet and find that the associated number for SIGKILL is 9, but is there linux documentation (such as, a man page) showing the complete list of signals and their numbers?
4
votes
4answers
3k views

Ctrl+C does not work in gnome-terminal

On my Linux host, Ctrl+C does not seem to work and I do not know how to proceed to make it work. I am using Ubuntu 10.04 with bash 4.1.5(1), and working in Gnome-terminal. When I pressed Ctrl+C while ...
4
votes
2answers
681 views

Why there are only two user defined signals?

In the list of signals defined in a linux system, there are two signals stated as User Defined signals (SIGUSR1 and SIGUSR2). Other signals will be raised or caught in specific situations, but SIGUSRs ...
4
votes
3answers
221 views

What process is running before I even get a prompt?

When I log in to a specific server I see the following: Note that I get get Last login: ... information but no prompt. I hit Ctrl+C and only then do I get my prompt, thus proving that my username ...
4
votes
3answers
1k views

Preventing propagation of SIGINT to Parent Process

Considering a scenario where a Parent program (could be a C++ program or a Shell Script) executes a Child shell script, when we hit Control+C (or whatever character is configured to be the INTR ...
4
votes
1answer
499 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 ...
4
votes
1answer
2k views

Why is my C++ program killed by OS

I've compiled small C++ application for school project on my virtual ubuntu 11.04. However when I attempt to run it over some larger data set after ~20 sec the program is killed by OS. Killed ...
4
votes
2answers
866 views

Process descendants

I'm trying to build a process container. The container will trigger other programs. For example - a bash script that launches running background tasks with '&' usage. The important feature I'm ...
4
votes
1answer
493 views

A script's background process is still alive after closing the terminal

This is more of a process management/signal handling question than a Bash question. It just uses Bash to explain the issue. I'm running a Bash script in which I run a background process. This is the ...
4
votes
3answers
5k views

when does the system send a SIGTERM to a process?

My server program received a SIGTERM and stopped (with exit code 0). I am surprised by this, as I am pretty sure that there was plenty of memory for it. Under what conditions does linux (busybox) send ...
4
votes
1answer
953 views

How do I find out what process is consuming pending signals?

A user is getting the following message when they try to run a particular program. timer_create: Resource temporarily unavailable From this StackOverflow Q&A titled: timer_create() : -1 ...