Skip to main content

Questions tagged [signals]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
43 views

How to send a signal to a set of pthread within one process in Linux?

I am working on an embedded Linux system (kernel-5.10.24). There is a multi-threaded process needed to handle a certain of exception delivered through a signal. The process is something like below. ...
wangt13's user avatar
  • 443
3 votes
1 answer
92 views

sigqueue(3) semantics

The manpage for sigqueue(3) says that an integer or pointer may be passed as a parameter to the process that receives the signal. Would passing a pointer imply that the sender and receiver already ...
Mark Morgan Lloyd's user avatar
4 votes
1 answer
780 views

What is the correct way to unconditionally kill a process?

I have two hotkeys for interactively looking up and killing a process on Linux: bindsym $mod+k exec --no-startup-id \ "ps axo pid,cmd | sed 1d | dmenu -i -l 20 | awk '{print $1}' | xargs kill&...
Fadeway's user avatar
  • 153
0 votes
1 answer
50 views

How is PID 1 made special and unkillable?

Using docker, I recently found that PID 1 is by default unkillable by SIGTERM. Yet you can still catch SIGTERM in PID 1 if you setup a handler in the process. So this doesn't seem to be the case of ...
rrauenza's user avatar
  • 774
3 votes
1 answer
285 views

SIGPIPE and bash pipefail

I am trying to better understand SIGPIPE on linux. I ran this experiment: { ls -al /tmp/ ; echo "$?" 1>&2 ; } | head and it echos 141 which I understand is an exit code that is given ...
Dave Butler's user avatar
0 votes
1 answer
48 views

SIGTSTP(Ctrl-Z) not working for script started by script command

Note: script refers to the script command, which logs stdin and stdout to files. I was trying to run a script with the script utility to save output for later inspection while preserving text colors ...
GoDaft WithEBK's user avatar
1 vote
0 answers
27 views

How does siglongjmp work with multiple signal handlers

I am following the APUE textbook on siglongjump(), and there is this piece of code which is confusing me. pr_mask() is simply a function which prints the signals which are masked. According to this, ...
Shivanshu Arora's user avatar
2 votes
1 answer
120 views

When SIGTERM is received by a process, what happens to its children?

I am wondering what happens when a process receives SIGTERM and it has children spawned (e.g. JVM that has /bin/sh commands running). Is there some sort of automatism or does the parent simply exit ...
RokL's user avatar
  • 143
0 votes
0 answers
61 views

how to send signal to (parent process?) telling the parent that the child is crashing

This is probably not a best practice, but I am trying it out. I have this entrypoint.sh file that I use with docker like so: ENTRYPOINT ["./entrypoint.sh"] here was entrypoint.sh: #!/usr/...
Alexander Mills's user avatar
0 votes
0 answers
59 views

What could be causing processes to be suspended?

This excerpt from a shell session says it all: brandon@Air ~ % brew upgrade rust ... ==> Pouring rust--1.75.0.arm64_monterey.bottle.tar.gz [1] + 76816 suspended (signal) brew upgrade rust ...
iconoclast's user avatar
  • 9,258
1 vote
1 answer
76 views

What does code number mean in unhandled signals?

I run a custom GNU/Linux distro on an RISC-V Ariane CVA6 processor running on a custom design on an FPGA. I am getting a bus error when I try to read from a memory mapped I/O register. I have verified ...
Galux Trabakoulas's user avatar
0 votes
2 answers
670 views

Cannot easily kill child processes started with bash

In general I find child processes to be a nightmare - if I have this: #!/usr/bin/env bash ( proc_one ) & ( proc_two ) & wait if i ctrl-C this script, they still running the background and ...
Alexander Mills's user avatar
4 votes
0 answers
47 views

Perl's `kill` is using `$! == Errno::EINTR` unexpectedly

I wrote a network daemon that forks off children to handle TCP connections. On SIGINT the main process triggers a kill for each child in order to clean up and to collect some final statistics. In ...
U. Windl's user avatar
  • 1,493
0 votes
0 answers
33 views

How to interpret different behavior of sleep and wait when they are interrupted

I'm trying to understand the subtleties between sleep and sleep & wait. If run the script test.sh #!/bin/bash sleep 10000 in one terminal and ps -aef --forest in another terminal, then I see ...
user1335014's user avatar
1 vote
1 answer
2k views

trying to make my own shell handle ctrl+c properly

I am trying to understand how shells are set up so that the programs they are running receive the SIGINT when you press ctrl C but the shell doesn't, because when you are running bash, and run another ...
Alex028502's user avatar
1 vote
1 answer
65 views

Background process is not being terminated by SIGINT when executed via ssh

I was experimenting with ssh, nohup, bg etc. I started a tail process in remote using $ ssh remotehost '{ nohup tail -f ut.log &> /dev/null < /dev/null &} && echo $!' It ...
Sourav Kannantha B's user avatar
1 vote
1 answer
382 views

Where does the signal that causes EINTR come from?

I Understand that EINTR is an error which so-called interruptible system calls may return. My question is where does the signal that causes EINTR come from? I faced this quite often when using fnctl ...
chewing gum's user avatar
1 vote
1 answer
256 views

Freebsd12: Process killed instead of swapping out

I run FreeBSD 12 through Vagrant on a VM with 350 MB RAM and 2 GB swap. If I run: perl -e '$a="x"x200_000_000;sleep 1000' & sleep 10 perl -e '$a="x"x200_000_000;sleep 1000' &...
Ole Tange's user avatar
  • 35.8k
0 votes
0 answers
237 views

Process not stopping even after receiving Ctrl-Z

I was learning about signal handlers. I wrote a simple python script to handle and print all signal it gets. Then I ran that script on a remote machine through ssh. Then when I send Ctrl C signal, the ...
Sourav Kannantha B's user avatar
0 votes
0 answers
105 views

Memory protection keys: Exception handler crashes if pkey0 is write-disabled

Background: in-process isolation based on memory protection domains in x86/linux using memory protection keys (MPK) and the protection key register PKRU. Setup: The program first executes ...
Robert Kueffner's user avatar
0 votes
2 answers
319 views

How can I make my looping shell script pause after a loop by sending something like ctrl-z and then be continuable?

I have a shell script that loops over files. Processing each file can take several hours (it is CPU/GPU-limited). Sometimes I want to pause the execution at the end of a loop, when a file is finished ...
d-b's user avatar
  • 1,947
5 votes
3 answers
913 views

How to cleanup on suspense (ctrl-z) in a Bash script?

I have the following script: suspense_cleanup () { echo "Suspense clean up..." } int_cleanup () { echo "Int clean up..." exit 0 } trap 'suspense_cleanup' SIGTSTP trap '...
Sebastian Carlos's user avatar
5 votes
1 answer
622 views

Why does sending a trapped signal cause `read` to return in POSIX shell but not in Bash?

I was trying to write a shell script that idly waits for a signal in the background. Since the script doesn't take user input I thought of using read to block the script indefinitely while waiting. In ...
yvay's user avatar
  • 53
0 votes
2 answers
79 views

Is any desktop using SIGSTOP save CPU performance?

On GNU/Linux I can send the SIGSTOP signal with $ kill -STOP Then I can send SIGCONT to activate it again, That saves CPU performance from being used up like 11% from a minimised Firefox window "...
rich's user avatar
  • 1
0 votes
0 answers
25 views

Why does this script get to linger after having seemingly exited from Ctrl-C? [duplicate]

I have a script, script-A, which runs script-B. When run under the terminal, it terminates as expected from Ctrl-C, but when run via ssh it continues to silently run after Ctrl-C even though ssh ...
yong's user avatar
  • 351
1 vote
1 answer
236 views

^C SIGINT does not work in adb shell in Linux

I am working on an embedded Linux system, which uses kernel-5.10.24. It uses busybox as init, and has other utilities in rootfs, including adbd. I can run adb shell from PC to login to the embedded ...
wangt13's user avatar
  • 443
2 votes
3 answers
4k views

how to diagnose the originator of the signal 15 send to sshd

I recently met a issue that my sshd keep dead repeatly, I did the following check. from the /var/log/message, I could see the sshd keeped restarting Apr 23 12:05:39 host1 systemd: Stopping OpenSSH ...
wang larry's user avatar
0 votes
1 answer
742 views

How to track all signal in 'trap'?

Can I test keyboard shortcuts and some kill commands with a script and know which signal is caught by trap?
Gilles Quénot's user avatar
0 votes
0 answers
121 views

sigtimedwait sets errno to ETIMEDOUT with timeout=0

In a cpp multithreaded program, we're using a copy of Linux sigwait implementation at the end of our main function, after creating all threads and initializing our program: sigset_t mask; ...
binks's user avatar
  • 1
2 votes
0 answers
731 views

It's possible to force a graceful shutdown when you kill a QEMU process?

I'm working with a Ubuntu VM with QEMU, I understand that when the Host (Mac M1 in my case) makes a shutdown sends a SIGTERM to all processes, but when arrives the signal to QEMU the Ubuntu does ...
Javier Tacón's user avatar
1 vote
1 answer
2k views

Trapping SIGINT so that the process kills itself

So section 5 from here made sense to me and I wanted to implement it. I have this bash script #!/usr/bin/env bash cp aux.sh aux.sh.bak cleanup() { cp aux.sh.bak aux.sh rm -rf aux.sh.bak } ...
leo's user avatar
  • 113
4 votes
1 answer
198 views

Inside less, is there an equivalent of ctrl-Z to recover the pager prompt?

I will occasionally use the pickaxe functionality of git to locate changes of interest. This can be quite slow, obviously (the same would apply to, say, hg grep), but more significantly it is bursty: ...
Pierre Lebeaupin's user avatar
1 vote
1 answer
2k views

Process not receiving SIGTERM in Docker container

I've got a simple Python process running in a Docker container: Dockerfile: FROM ubuntu:18.04 RUN apt -y update && apt -y install python3 COPY app.py /app/ WORKDIR /app ENTRYPOINT ["./app....
Daniel Walker's user avatar
0 votes
1 answer
992 views

Make systemd treat unexpected exit as failure

I'm wrapping a 3rd party executable in a systemd service unit to manage it. I can't alter the behavior of this program and I don't really trust its exit codes. I would like to treat any exit that ...
davolfman's user avatar
  • 672
1 vote
1 answer
224 views

Send and trap SIGTTIN SIGTTOU in foreground process?

From the description of signals (reference), it seems like SIGTTIN and SIGTTOU are sent to a process only if it is in background. Pressing Ctrl-s does stop printing in terminal, if such flow control ...
codepoet's user avatar
  • 596
44 votes
3 answers
7k views

How is a signal "delivered" in Linux?

I am confused by the terminology used to describe Linux signal delivery. Most texts say things like "the signal is delivered to the process" or "the signal is delivered to the thread&...
Albert's user avatar
  • 531
2 votes
1 answer
330 views

How to stop program of non-interactive SSH call without pseudo-terminal

Let's say I start a program with a non-interactive SSH call (without pseudo-terminal) and exit the session via CTRLC: $ ssh user@server -- sleep 123 ^C This way, the program, in this case sleep 123 ...
finefoot's user avatar
  • 3,142
0 votes
1 answer
108 views

Trapping shell script doesn't work when used over SSH [duplicate]

I am working on client and want to run a script on server which includes a trap. The following minimal example works fine if I connect to server and run it in an interactive SSH session: user@client:~$...
finefoot's user avatar
  • 3,142
0 votes
1 answer
127 views

Why does the `man` command not handle SIGINT or SIGQUIT?

When using man, I noticed that you need to use the q key to exit instead of using CTRL + C (SIGINT) or CTRL + D (SIGQUIT) signals. Is there any reason for this? I couldn't find anything in the man ...
LeoDog896's user avatar
  • 149
0 votes
0 answers
68 views

Linux Script Command Ignores Exit Code on Signal Interrupt

I am using the script command to run a C program that handles SIGINT signals and just exits gracefully. A small example of my C code: #include <signal.h> #include <stdio.h> #include <...
Etchy's user avatar
  • 1
0 votes
1 answer
87 views

How to send new information to STOPped process

Say I have a long-running process, and I stop and restart it using: kill -STOP <pid> kill -CONT <pid> is there a consistent way to alter the running process, either environment variables ...
Alexander Mills's user avatar
5 votes
1 answer
641 views

How can I make a script echo something when it is paused?

I am pausing a terminal script with SIGSTOP, and I want it to print a message that it is being paused. Since I can't trap the SIGSTOP, I've tried sending a SIGUSR1 before the SIGSTOP and trapping ...
Adam M's user avatar
  • 51
0 votes
2 answers
541 views

Can't Ctrl-C a script after controlling it from another terminal

I'm running blah.sh in one terminal. Then in another terminal, I'm running a script that suspends and later continues blah.sh: ... script_id=`pidof -x blah.sh` kill -s SIGSTOP $script_id ... ...
Adam M's user avatar
  • 1
0 votes
1 answer
2k views

What is the meaning of `kill -0 <pid>`? [duplicate]

I found in a script a call to kill -0 <pid>. It looks like a way to check if process exists. I don't know the exact meaning of kill -0 so I looked for its definition but I didn't find any ...
karlacio's user avatar
  • 101
1 vote
0 answers
901 views

Inside a Docker container, `tini` should be proxying signals to my Java app, but it doesn't seem to be doing so

I'm using tini as my init process to allow me to launch a Java app via a shell script in a container and have my app get signals from Docker when the container is stopped. Given that the problem ...
CryptoFool's user avatar
0 votes
1 answer
92 views

Fail handling SIGINT in hierarchical process execution

I have the following process execution structure: script0.sh script1.sh script2.sh script3.sh Meaning: script0.sh executes script1.sh. script1.sh executes script2.sh and script3....
Dor's user avatar
  • 2,555
0 votes
1 answer
290 views

Does a handled SIGINT affect pipe communication with a child process?

I have an interactive C program that reads a phrase from the terminal, and computes a series of anagrams. I also have a Perl program that reads and buffers lines from STDIN until receiving a reserved &...
Chap's user avatar
  • 389
3 votes
1 answer
640 views

Signal handling in shell script with exec and pipe to filter output with grep

I'm deploying a containerized application which outputs an enormous amount of useless messages on startup (the same message for about a million times, without any variation). The message cannot be ...
Namoshek's user avatar
  • 133
0 votes
1 answer
498 views

Linux Log file for signals

Just wondering any log file I can check in Debian if my colleague sigstop or sigterm my process during I'm away? I've checked syslog, message files. But wasn't able to find any relevant log. Or any ...
Hardguy's user avatar
  • 59
1 vote
1 answer
329 views

Load a process into RAM, but don't execute?

Is there a way to load a process into RAM, but somehow tell the scheduler not to execute it? The aim being to have the system read the binary from disk, allocate the pages in RAM for the code, but not ...
Ralph Bolton's user avatar

1
2 3 4 5
13