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

0
votes
1answer
18 views

Detect power loss

Is it possible to detect loss of power on a laptop/desktop without an UPS? Obviously a computer without an UPS will shutdown at least almost immediately after being unplugged/having its battery ...
30
votes
4answers
2k views

What happens when a non-root user sends signals to root user's process?

I'm wondering about the security of UNIX signals. SIGKILL will kill the process. So, what happens when a non root user's process sends a signal to a root user's process? Does the process still ...
1
vote
1answer
43 views

SIGINT handling differences between bash 3 and 4

I have a script which works great in bash 4.3, but gives me unexpected behavior with bash 3.2. Here's a simplified version: set -o errexit -o pipefail task() { local name=${1} local ...
214
votes
4answers
18k views

How does a Segmentation Fault work under-the-hood?

I can't seem to find any information on this aside from "the CPU's MMU sends a signal" and "the kernel directs it to the offending program, terminating it". I assumed that it probably sends the ...
4
votes
2answers
116 views

What happends when sending SIGKILL to a Zombie Process in Linux?

In Linux, when a child process terminates and it's parent has not yet waited on it, it becomes a zombie process. The child's exit code is stored in the pid descriptor. If a SIGKILL is sent to the ...
5
votes
1answer
47 views

Ctrl+c and Ctrl+z to interrupt/suspend jobs

To kill a hanging job, I use Ctrl+c, to send an interrupt signal to the hanging job. Sometimes this wouldn't stop the job, at least not immediately. I can then use Ctrl+z to suspend the job and then ...
3
votes
1answer
54 views

sigint not being propagated to background child process

I need to send SIGINT to terminate a process gracefully but I can't. This is a sample, because the environment in which the execution occurs is 'unknown' (a bash script in travis.com) I managed to ...
14
votes
3answers
1k views

In `dmesg | head`, (how) is dmesg being killed after 10 lines of output? [duplicate]

If I run these commands: dmesg | head -n 10 I presume the OS sends back some kind of signal to dmesg once head has read 10 lines. How does this work? What does head tell the kernel? This is ...
3
votes
1answer
41 views

`EINTR`: is there a rationale behind it?

Small talk as background EINTR is the error which so-called interruptible system calls may return. If a signal occurs while a system call is running, that signal is not ignored and a signal handler ...
1
vote
1answer
37 views

use exec -a to name process but run it in the background immune to CTRL-C

I would like to start a background process from bash script, but at the same time give it another name and also make it immune to CTRL-C. I tried the following: exec -a NiceName java -cp ....long ...
1
vote
2answers
87 views

How can I wake a process from sleep status via signal or /proc?

Many years ago I had an issue with Linux where processes would randomly go to sleep. Back then, I knew a trick with the /proc filesystem to trigger a wakeup of the process. I vaguely remember being ...
3
votes
1answer
42 views

Difference between less violent kill signal -HUP (1) -INT (2) and -TERM (15)

Apart from the most violent kill -9 (SIGKILL), I don't quite understand the difference between the 3 other common signals (here) -HUP (1), -INT (2), and -TERM (15). In which scenarios would one work ...
3
votes
4answers
47 views

Is there a variant of watch that only refreshes upon receiving a signal?

I have a window that runs a somewhat expensive watch git log ... incantation — expensive enough that it actually looks more like watch -n30 timeout 10 git log ... so that it doesn't excessively ...
1
vote
1answer
14 views

Does SIGHUP get triggered upon broken telnet/SSH connection?

I'm trying to write a mail program which might contain data that a user wouldn't want to lose upon a broken SSH/telnet connection. Would SIGHUP be sent to the process? After all, it's the "hangup" ...
10
votes
1answer
142 views

Why does a while loop stop after being suspended?

Why is it that using bash and suspending a while loop, the loop stops after being resumed? Short example below. $ while true; do echo .; sleep 1; done . . ^Z [1]+ Stopped sleep 1 $ ...
2
votes
1answer
42 views

Xvfb not sending SIGUSR1, breaking xvfb-run

I've been working a knotty problem trying to run headless tests using the xvfb-run script provided with Xvfb. It works on my own Ubuntu images running in VirtualBox, but on the Ubuntu 15.04 AMI that ...
2
votes
1answer
62 views

Bash shell launched by forkpty() spawns child processes that ignore SIGINT. Why and how do I ensure SIGINT is not ignored?

I have a C program that uses forkpty to execute a bash shell. I'm finding that the programs launched by this shell are launched with SIGINT ignored, so when I send a Ctrl-C to the shell they never ...
1
vote
1answer
65 views

Signal execution details

I am reading some Linux documentation about 'signals' and I still have these questions making noise in my mind: 1) A 'signal' handler execution is done when the 'target' process receives its ...
4
votes
1answer
47 views

What is signal queue depth in Linux

How many signals can be queued on a process that has all signals blocked? What if I use sigqueue() more often then that limit? Will those signals not be queued? Will I get an error?
2
votes
2answers
86 views

Why doesn't SIGSTOP work inside screen session?

Consider the following script: #!/bin/bash OFILE='log' echo 'ok' > ${OFILE} kill -SIGSTOP $$ echo 'after stop' > ${OFILE} In an interactive shell the script is stopped and the output is ok. ...
2
votes
0answers
24 views

Why does pacman stop when I freeze the output with ctrl+s

I sometimes use ctrl+s to send an XOFF signal to freeze the output of a program without stopping the program itself. However, pacman, unlike most other programs, stops as if you had pressed ctrl+z. It ...
6
votes
4answers
320 views

How can I handle SIGINT trap with a user prompt in shell script?

I am trying to handle SIGINT/CTRL+C interrupt in such a way that if a user accidentally presses ctrl-c, he is prompted with a message, "Do you wish to quit?(y/n)". If he enters yes, then exit the ...
2
votes
2answers
36 views

Can a tty be made unkillable?

I used PuTTY to ssh into a linux machine from a windows machine and I was just messing about with the pkill command. I quickly found out that I could log out of a remote session by typing w to show ...
1
vote
0answers
18 views

How do I escalate a signal?

For the past week, I been having a bug that my python code hasn't been doing a cleanup process properly. It was suppose to once it captures a signal caused by closing the terminal, it does some ...
1
vote
0answers
49 views

CentOS Running process not responding to kill signals and not context switched

An updatedb process on my linux server is not responding to kill signals. (kill -9 or SIGSTOP) [root@chroot-1 ~]# ps auwx | grep -i 4505 root 4505 99.5 0.0 59544 1256 ? RN 09:43 ...
5
votes
2answers
192 views

Keep exit codes when trapping SIGINT and similar?

If I use trap like described e.g. on http://linuxcommand.org/wss0160.php#trap to catch ctrl-c (or similar) and cleanup before exiting then I am changing the exit code returned. Now this probably ...
0
votes
0answers
19 views

Program is not launcher in function that is called by a signal trap

I have a bash script that requires some cleanup commands to happens when it gets closed in the console. Basically the cleanup is a restart command in my python deamon progarm (Lets call this P), ...
2
votes
0answers
61 views

What signal is sent when you close a bash terminal to the programs it was running

I have a bash script that launches a python program. The bash script handles SIGINT SIGTERM and SIGHUP signals to do a cleanup operation. I noticed that when I close the process in a tab in ...
3
votes
1answer
95 views

Sending sigaction / sigqueue through shell

I have a c++ program that handles several signals to perform different actions, using signal: signal(SIGHUP, signal_handler); I wanted to extend this signal handling to allow me to send ...
12
votes
7answers
1k views

Unable to stop a bash script with Ctrl+C

I wrote a simple bash script with a loop for printing the date and ping to a remote machine: #!/bin/bash while true; do # *** DATE: Thu Sep 17 10:17:50 CEST 2015 *** echo -e "\n*** ...
0
votes
0answers
34 views

How often is SIGHUP called in this situation?

I have situation where I am connected to my BeagleBone Black over USB cable, and I started my application in Linux terminal and I'm watching its execution, it sends me some data to terminal and it ...
1
vote
0answers
14 views

How do I terminate Aptitude safely

I have a TMux session with Aptitude open. The Aptitude process has been "killed" several times with STOP/CONT. Now it doesn't react to the Q key. Instead a 'q' is printed on the top-left corner of the ...
6
votes
1answer
307 views

Difference between closing the terminal using the closing button, and Ctrl-D

When I'm launching a background process and then closes the terminal using the window's closing button, the background process gets killed. However if I close the terminal using Ctrl+D, the background ...
1
vote
2answers
213 views

Cannot rewrite “trap command” for SIGTSTP, SIGTTIN and SIGTTOU

I want to trap the SIGTSTP signal, but I'm not able to. When I call just trap command without arguments, I'm getting this: trap -- '' SIGTSTP trap -- '' SIGTTIN trap -- '' SIGTTOU Obviously, my ...
1
vote
3answers
68 views

New signal arrives while execution is in a signal handler, how to decide which is first?

I am working on a tool handling a massive amount of signals (with different signums) with sigaction(). I need to handle the case, if a new signal is coming, while the previous was in a signal ...
1
vote
0answers
174 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 ...
6
votes
2answers
229 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 ...
8
votes
2answers
565 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
1answer
35 views

Which process group does my program belong to when started from bash?

If I run a program from bash, then does my program belong to the same process group as the shell, or does it belong to a new process group? As I am making a shell in C, I need to handle the SIGINT ...
0
votes
1answer
359 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?
1
vote
2answers
97 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 ...
-1
votes
1answer
53 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 ...
2
votes
2answers
61 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 ...
2
votes
0answers
27 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 ...
5
votes
1answer
138 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
94 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 ...
13
votes
1answer
279 views

Update bash history on other terminals when exiting one terminal

I know this question is not obscure, as it is asked here keep updating (and duplicated here). What I'm trying to achieve is a bit different. I don't like the idea of my prompt rewriting a file every ...
3
votes
1answer
71 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
135 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 ...
2
votes
3answers
6k 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 ...