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

1
vote
0answers
20 views

Not sure how signal handler is being called [migrated]

Code: #include <signal.h> static void sigHandler(int sig) { printf("Ouch!\n"); } int main(int argc, char *argv[]) { int j; if (signal(SIGINT, sigHandler) == SIG_ERR) ...
2
votes
1answer
44 views

Forward SIGTERM to child in Bash

I have a Bash script, which looks similar to this: #!/bin/bash echo "Doing some initial work...."; /bin/start/main/server --nodaemon Now if the bash shell running the script receives a SIGTERM ...
1
vote
0answers
23 views

Trap not trapping SIGTSTP

I have a script that keeps displaying the login prompt: #!/bin/bash trap '' 2 20 while true; do login done This is part of a bigger project so please don't tell me to just use the system login ...
0
votes
2answers
36 views

Idiomatic way to kill -9 only if “graceful” way doesn't work?

Is there a common way or existing utility to do the following? kill a process Give it a few seconds to shut down gracefully kill -9 it if it hasn't stopped
3
votes
2answers
52 views

How to programatically detect when a device raises an interrupt?

How to programatically detect when a device raises an interrupt? This can be when a device is connected or disconnected. And also this case: for example: when a finger is held over a fingerprint ...
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 ...
1
vote
1answer
24 views

How do I obtain the kill signal / message / reason within a script?

I am using the following trap: trap OnExit EXIT And in my OnExit function I would like to capture all the info I can on what happened so I can write it to a log file. Id like to know who, why, how, ...
2
votes
1answer
30 views

What signal does X send to its clients when it receives SIGINT?

If I terminate the Xorg server with a SIGINT signal (eg. when I press Ctrl+C), what signal does it send to its clients?
2
votes
1answer
53 views

Does this dispatcher produce zombie process?

I have such a dispatcher shell script. while read line do java TestProg $line & done < $tasklist On the zombie process Wikipedia page, it says if a parent fails to call wait, the ...
3
votes
1answer
34 views

SIGKILLing after a grace period

I've seen a lot of process managers that try to do this. It was my understanding that you should only use SIGTERM to kill a process. The process could take an unknown amount of time to clean up after ...
0
votes
0answers
34 views

Execute snippet of code when key is pressed [duplicate]

I want to create a process in Linux which waits for some particular keys to be pressed and executes a snippet of code and goes back to sleep. How can I achieve this? Initially a process will be in ...
2
votes
1answer
280 views

ctrl c vs. ctrl z with foreground job

Ctrl+Z stops the job whereas Ctrl+C kills the job. Why is that? Wouldn't the other way make more sense? z@z-lap:~$ sleep 100& [1] 4458 z@z-lap:~$ sleep 200& [2] 4459 z@z-lap:~$ jobs [1]- ...
7
votes
1answer
124 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. ...
11
votes
2answers
558 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 ...
0
votes
0answers
77 views

Archive (Compress) giant folder in Linux using command line without termination

Well, I'm just trying to compress a whole directory (infact giant!) under Linux using a terminal. The entire folder size is about 7 GB. I've used below command to create the archive. tar -zcvf ...
2
votes
3answers
95 views

CTRL C behavior in hierarchy of shells

First of all sorry about terminology errors, I'd try to be clear. I open a shell (like sbt or node debug from my bash). Then inside this shell, I open another one (using scala or node repl ...
3
votes
5answers
618 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? ...
0
votes
2answers
152 views

Disable the display of “terminated xxx” info of bash

For example, when I kill a background process, then bash weil display terminated xxx, How to disable this info? $ ping g.cn >/dev/null & [1] 25123 $ pkill ping [1] + 25123 terminated ping ...
2
votes
1answer
39 views

calling sigprocmask from bash

I have a process that spawn a bash command with system() while the signal mask has all the signals blocked. This cannot be fixed easily. The bash command eventually execs into a process. The all ...
2
votes
2answers
33 views

Does time window still exist when the signal is not blocked

Many books say that a time window exists between the generation and delivery of the signal when the signal is not blocked. So I wonder whether the time window still exists when the signal is not ...
2
votes
2answers
109 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, ...
1
vote
1answer
120 views

service killed at ssh hangup [duplicate]

If I use ssh to run some command in background, that command gets killed as soon an ssh hangs up: ssh localhost -t "bash -c '(for i in 1 2 3 4 5; do sleep \$i;done)&'"; ps x|grep sleep This ...
5
votes
2answers
247 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 ...
3
votes
4answers
2k views

Ctrl-C with two simultaneous commands in bash

I want to run two commands simultaneously in bash on a Linux machine. Therefore in my ./execute.sh bash script I put: command 1 & command 2 echo "done" However when I want to stop the bash ...
0
votes
2answers
128 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 ...
1
vote
1answer
524 views

Ctrl-C handling in SSH session

When I start an SSH session that executes a long-running command, what happens with Ctrl+C (SIGINT) handling? I can see that the SSH session is closed, but I am not sure who gets the SIGINT first: is ...
2
votes
2answers
170 views

Pipe command to tail: when is the first command aborted?

In this example: $ for i in {1..3}; do sleep 1; echo $i; done | head -n 2 why is the first command (for loop) killed only just before the 3 is displayed ? I expected it to be killed right after ...
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 ...
2
votes
1answer
264 views

Suppress “Alarm clock: 14” from ping

I've made a simple script for rebooting my router and afterwards showing a progress bar until my computer has an internet connection again. When running the script I get the following output: The ...
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 ...
2
votes
1answer
747 views

child process does not inherit the pending signals from the parent after a fork system call, why?

Could anybody please tell me the reason to why pending signals are not inherited by the child process? On the other hand, the child process inherits the signal handlers and signal mask from the ...
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. ...
0
votes
1answer
45 views

Does Control+C delete the files that you were downloading and installing? [closed]

If you are installing a package in the terminal and you use Control+C to stop it, does it also undo all the changes and remove the files that it downloaded?
1
vote
2answers
792 views

How to generate signal interrupt on a file descriptor in Linux?

How can I generate a signal interrupt on a file descriptor in Linux? Motivation is to generate a interrupt in userland as we have in microcontrollers. I'll have file descriptor for I/O, and want to ...
1
vote
1answer
89 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 ...
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.
7
votes
1answer
680 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 ...
4
votes
1answer
970 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 ...
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 ...
12
votes
2answers
894 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 ...
7
votes
1answer
300 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 ...
2
votes
1answer
241 views

Keyboard shortcut for SIGTERM in GUI application?

Related to another question, is there a way to send SIGTERM to the currently focused local GUI window application with a keyboard shortcut? Like clicking the [X] button in most WMs or Ctrl-c for the ...
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 ...
4
votes
3answers
223 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
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 ...
2
votes
2answers
178 views

End process from another SSH window

I forgot to use screen and I have a task that has been running for quite some time, and I do not want to lose the saved data. Basically Ctrlc will end the task and save the data if I am on the same ...
3
votes
1answer
676 views

sigaction(7): semantics of siginfo_t's si_code member

I've got a long-running program (becomes a daemon with daemon(3) call) that exits on Signal 11 (Segmentation Violation) every so often. I can't tell why. So, I wrote a SIGSEGV handler, set using the ...
2
votes
2answers
347 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 ...
1
vote
1answer
2k views

System sending SIGTERM and SIGKILL during normal work

I have a program (C++) that works with TCP sockets in multithreaded manner. The multithreading is intensive, about 100 threads (POSIX threads). Sometimes, not quite sure when, the program gets ...