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
30 views

What happens to a multithreaded Linux process if it gets a signal?

If a Unix (Posix) process receives a signal, a signal handler will run. What will happen to it in a multithreaded process? Which thread receives the signal? On my opinion, the signal API should be ...
20
votes
4answers
14k 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 ...
5
votes
1answer
249 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 ...
4
votes
1answer
9k 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]- ...
5
votes
2answers
113 views

In zsh, how can I more quickly disown the foreground process?

My method for disowning the foreground process takes too much effort. Suppose I have a process in zsh's foreground. I want to disown it, so I can close the shell without the process being sent a ...
6
votes
2answers
107 views

Kill a suspended process?

I was slightly confused by: % vim tmp zsh: suspended vim tmp % kill %1 % jobs [1] + suspended vim tmp % kill -SIGINT %1 % jobs [1] + suspended vim tmp % kill -INT %1 % jobs [1] + suspended ...
1
vote
2answers
53 views

Wrong eUID in `/proc/PID/status` when SETUID is used

While doing a wargame challenge, I ran into an issue with permissions. The info given by /proc/PID/status is not in adequation with the permissions that should be given to the processus. I am user ...
0
votes
1answer
64 views

Disable ctrl c and ctrl z while a script is running

I have a script that takes about 45 seconds to run. How can I disable Ctrl-c and Ctrl-z while a script is running?
13
votes
5answers
4k 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 ...
11
votes
2answers
3k 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
votes
1answer
19 views

Daemon opens a file in RO mode only

I am trying to write a kind of keylogger myself. I don't know if my logic of developing a keylogger is good or not but I have thought of doing it the following way. First a daemon is created, and to ...
5
votes
1answer
140 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
2answers
48 views

How to make this loop Ctrl+C-interruptible?

# wait for host to become online while true; do ping host -c 1 -w 3 > /dev/null && break; sleep 1 done When I press Ctrl+C, the ping receives it and exits with exit code 1 (the ...
12
votes
4answers
8k 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 ...
2
votes
0answers
24 views

Data written to /dev/pts/x inside SIGINT (Ctrl+C) handler is randomly discarded [closed]

Have Archlinux64 on VirtualBox. If I declare a SIGINT trap like this: trap 'echo x' INT inside an ssh session (running bash) and press Ctrl+C multiple times, only a few times does something appear ...
7
votes
3answers
4k 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 ...
4
votes
1answer
96 views

Is there a command line tool to manage unix signals?

Is there a command runner like env, nice, nohup, etc., that can run a program with modified signals? In my case, I need something to reset SIGINT to SIG_DFL. Why do I need this? Because ...
1
vote
1answer
53 views

Is there a robust way for a child process to signal readyness to its parent? [closed]

I have a (Java) process which is staring a separate process foo. foo takes some number of seconds to start up, then is really running. Control returns back to the parent process as soon as foo is ...
18
votes
6answers
41k views

How to stop the loop bash script in terminal?

For example, #!/bin/bash while : do sl done How to terminate this bash script?
13
votes
1answer
211 views

Update bash history on others terminals on exit of one

I know this question has a similar interpretation, as its asked here keep updating (and duplicated here). But what I'm trying to achieve is a bit different. I don't like the idea of my prompt ...
1
vote
2answers
3k 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 ...
3
votes
1answer
48 views

Sending signals to long-running processes (AWK, DD)

I'm familiar that DD command doesn't produce output while running. However, if I send a USR1 signal to it, it can print current state. Can I do the same with AWK? Prints its variables, register ...
1
vote
1answer
68 views

TTY control characters sent to stdin of sh doesn't work

I tried to develop a remote app that launches sh and resends an incoming data there, and found that some special sequences don't work. So, for testing purposes, I launched on my desktop sh, then ...
3
votes
3answers
818 views

How to restart (or reset) a running process in linux

I have two Linux systems communicating over sockets (Desktop and ARM-based development board). I want to restart (or reset) my client application (running on a development board) when server sends a ...
10
votes
2answers
1k 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. ...
5
votes
2answers
393 views

What are pending signals?

When looking at the limits of a running process, I see Max pending signals 15725 What is this? How can I determine a sensible value for a busy service? Generally, I can't seem to find a ...
7
votes
1answer
54 views

What happens to requests to a service that is stopped with SIGSTOP

If you run SIGSTOP against a web server, does the kernel just tell the network stack to block/sleep all connections to that socket until it is continued? It seems that the server timeout values don't ...
3
votes
1answer
46 views

Why does my application die without nohup?

I have a simple system (running on Debian) that works by invoking a script from /etc/init.d/rc.local At the bottom of rc.local I call myScript.sh who sets up some things, and then starts a binary ...
2
votes
0answers
212 views

SIGINFO on GNU Linux (Arch Linux) missing

I am developing an application and I would like it to print some runtime stats to the console on demand. kill and signals came to my mind immediately. Reading through Unix signals on Wiki, SIGINFO ...
4
votes
2answers
350 views

Safely exiting while loops in bash

Say I have a bash script that does: while : do foo done I would like to be able to run this script from the console and be able to exit it at an arbitrary time as long as it happens in between ...
-1
votes
1answer
36 views

How to make a process wait in the background and be able to be killed by signal other than KILL

I want a script run in the background, take some actions for every hour. It should also quit if receiving a signal. And at last, it should perform some clean-up actions before quitting. Based on the ...
8
votes
4answers
10k 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 ...
2
votes
5answers
88 views

How to create a script that can't be easily exited

How would I create a script that does not respond to Ctrl-C? This should also prevent any processes launched by the script from being killed (I'm trying to keep apt-get upgrade from being killed). (I ...
1
vote
1answer
94 views

Ctrl+C process termination without Terminal killing

I started using Sublime Text 3 to compile my FreeFem scripts (interpretator PDEs package solver) under Ubuntu 14.04. To invoke the interpretator I customized the build system as follows "shell_cmd": ...
8
votes
3answers
3k 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
3answers
572 views

Control which process gets cancelled by Ctrl+C

I have a live CD that boots into Linux and runs a small Bash script. The script searches for and runs a second program (which is usually a compiled C++ binary). You're supposed to be able to abort ...
6
votes
1answer
86 views

HURD: Why is remote process not killed?

On most UNIX systems this will not leave a process running: ssh example.net sleep 1000 <<CTRL-C>> I have tested this behaviour on aix centos debian dragonfly freebsd hpux irix mandriva ...
2
votes
1answer
59 views

What's the easiest way to detect what signals are being sent to a process?

I'm trying to debug an issue with my shell (specifically, fish) sending signals to my background processes. I'd like to be able to recognize what signals a process is receiving. Ideally, I'd like ...
8
votes
2answers
479 views

Why does bash ignore SIGTERM?

Sometimes when I want to logout quickly I do kill -15 -1. I've noticed that bash is ignoring SIGTERM. I wonder what's the rationale for such bash behavior? It's not very UNIX'y to ignore SIGTERM ...
4
votes
2answers
571 views

On Ctrl+C, kill the current command but continue executing the script

I have a bash script, wherein I execute a line, sleep for sometime and then tail -f my log file to verify a certain pattern is seen, I press ctrl +c to get out of tail -f and then move to the next ...
3
votes
1answer
49 views

Parent restarted by child doesn't respond to CTRL-C

I wrote a program. It starts a process (call it A) that spawns a child process (call it D) that shutdowns and restarts A. Problem is, now I can't kill A nicely from the terminal (ie. CTRL-C isn't ...
3
votes
2answers
226 views

Is there any way to determine the signal that was caught from inside a bash trap function?

I have a bash script, in which I have specified via trap that a function will be called for any (catchable) signal. typeset -i sig=1 while (( sig < 65 )); do trap myfunc $sig let sig=sig+1 ...
6
votes
3answers
658 views

Can signal be ignored (lost)?

I have an application which is communicating with workers via signals (particullary SIGUSR1/SIGUSR2/SIGSTOP). Can I trust that whatever happens every signal will be delivered and processed by ...
39
votes
3answers
4k 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.
0
votes
1answer
98 views

timeout pipeline

I want to execute these two timeout command on the same command but with a different time and instructions. So timeout --signal=SIGINT 5s command timeout --signal=SIGKILL 10s command How to append ...
0
votes
1answer
50 views

Understanding a signal script

I have the following trap script but the idea about it, is little vague to me. #!/bin/bash for i in {1..64}; do trap "echo 'signal[$$] Caught signal SIG$(kill -l "$i")($i)'" "$i"; done; read -s ...
1
vote
1answer
161 views

Why cannot we kill a zombie? [duplicate]

I am editing this question since it was marked duplicate as another question about how to kill a zombie process. I am not looking for an answer to how to kill a zombie process. I do not have zombies ...
1
vote
1answer
36 views

How to propagate TSTP while running a program as a different user

I'm running a terminal application via "su" in this fashion: su -c "/path/to/app --args" username This is done from a root context, and 'username' is a less privileged user in the system. The ...
1
vote
1answer
296 views

fork() and how signals are delivered to processes

I program that I wrote in C fork()'s off a child process. Neither process will terminate. If I launch the program from the command line and press control-c which process(es) will receive the interrupt ...
0
votes
1answer
198 views

kill parent and child because endless loop

I have a process run by cron every hour. Such process calls another one (not sourced), ie: ./childProc.sh (Not sure if this detail is important) Because of an endless loop in child process (which ...