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

xargs and zcat: silence errors

Suppose I have: ** EDIT TO HAVE CLOSER CORRESPONDENCE TO ACTUAL USAGE ** find ... -regex ... | head -n 1 | xargs -I {} zcat {} | head -n 1 # next, I do some other things now, everything works ...
3
votes
0answers
44 views

Why does CTRL-C work in one user account but not another?

I have a bash script which is supposed to run a command every X seconds, until the operator interrupts it. Like this: test.sh #!/bin/bash while true; do echo Doing a thing... sleep 3 & ...
3
votes
1answer
147 views

Why is the integer value of SIGRTMIN (first real-time signal) 34 and not 32? [duplicate]

Examining the output of kill -l command $ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) ...
0
votes
1answer
46 views

How can I send specific (SIG) signal to systemd?

On systemd's manpage, there is a section called Signals, that talks about different signals and how they affect the system. For example, SIGRTMIN+3 reboots the system: SIGRTMIN+3 Halts the ...
3
votes
0answers
119 views

Is sigprocmask() not working correctly?

(Sorry for the long post but I wanted to be as accurate as possible) I was trying to print the signal mask of the main thread while writing a C program, when I came across something strange regarding ...
0
votes
0answers
21 views

How to capture what happens to the child processes when a (parent) SSH session is killed?

I've been trying to understand what causes child processes to die when the parent dies. In the below test, once I killed sshd, the child processes got killed, and did not get re-parented to systemd ...
2
votes
2answers
90 views

Why does SIGTERM work to terminate bash but not ash or dash?

Comparing bash, ash and dash, only bash can be terminated by SIGTERM kill -TERM <pid> For ash and bash, I need SIGHUP or SIGKILL kill -HUP <pid> kill -KILL <pid> What's the ...
0
votes
0answers
13 views

Not able to kill a process started in a script which is running on a device which is based on Ubuntu

I am trying to kill or interrupt a script that is running on an arm device that is based on Ubuntu. The script starts a program that has an infinite while loop after polling for an external trigger ...
1
vote
1answer
39 views

How to write into the actual editing buffer

I want "ls" to be written, but not executed, by stroking Control+r. I'm using the following code, but it writes the command into the buffer that will be used to execute after hitting Enter. I would ...
0
votes
0answers
20 views

How to set signal mask for child process started by bash

I have to set the signal mask for a C++ program/executable as workaround for a known issues by a bash start script. Known issues: Executable/C++ application has multiple threads (>1), the signal ...
1
vote
2answers
35 views

Underlying failure after a SIGPIPE

I am getting an error code 141 when running a bash script on a CI server that I cannot reproduce locally. After some searching, it sounds that error 141 indicates a PIPEFAIL, and I have a set -o ...
0
votes
1answer
45 views

Why SIGCHLD signal was not ignored when using wait() functions?

When using wait functions the SIGCHLD signal was consumed by wait when executing sample 1.1 as shown below. sample 1.1 if (pid==0){ printf("child\n"); printf("%d\n",pid); } else{ printf("...
1
vote
1answer
39 views

when are signals delivered?

Do the sender of signals trigger a context switch to the receiver's process to handle the signal? Or the receiver simply handles it when the process is scheduled to run?
0
votes
0answers
45 views

Receiving SIGKILL when children terminate

I want to receive SIGKILL instead of SIGCHLD when any of my forked children terminate. On Linux this is possible by passing a different child termination signal to clone()1. Is this possible on any ...
1
vote
1answer
27 views

Prevent SIGINT from reaching mysql subprocess

I have a perl script, which indirectly invokes mysql (to execute a long SQL script). I would like to disable Ctrl+C while that script is running, but somehow the signal still reaches mysql, which then ...
0
votes
1answer
65 views

Why does su command ignore SIGSTOP?

After entering su when I prompted to enter a password: user@debian:~$ su Password: I can't send SIGSTOP (ctrl+Z) from my keyboard (the same terminal) - nothing happens. So the only way to exit is to ...
1
vote
1answer
68 views

What is the function of the keyboard shortcut Ctrl+Y under Linux?

Below is excerpted from a well-known professor's site: Some signals cause a process to stop: SIGSTOP (stop!), SIGTSTP (stop from tty: probably ^Z was typed), SIGTTIN (tty input asked by ...
0
votes
1answer
80 views

Difference between Ctrl-C and kill -INT?

I have a signal handler in C++ program: void term(int signum) { cout << "in term" << endl; # Do Stuff exit(0); } int main(int argc, char *argv[]) { # Do Stuff signal(...
0
votes
0answers
27 views

How to kill a child process like TAR + XZ running from POSIX master script but called from BASH terminal prompt by a signal?

My script is (at the core) running this part, which obviously takes a long time if input_dir is large enough: XZ_OPT='-9 --extreme --threads=8 --format=xz --check=sha256 --verbose --verbose' \ tar --...
2
votes
1answer
65 views

Parent process doesn't do the default action after receiving SIGINT

I did 2 tests about SIGINT using Ctrl+C in bash. Test 1 Both parent script and child script set a handler by trap. # !/bin/bash # Parent.sh trap 'echo "I handled the SIGINT in Parent.sh and expect ...
0
votes
0answers
37 views

Will context switch happens in the middle of signal handler?

From my understanding, a signal handler can be interrupted by another signal.Is the interruption a real 'interruption'? Or it is because a context switch can happen during the middle of a signal ...
2
votes
1answer
44 views

Does SIGQUIT not have the effect of terminating a script in bash?

#!/bin/bash -- echo "$$" LC_ALL=C sed 's/[!-~]/b/g' /tmp/bigfile > /tmp/outfile echo end of script If I send the QUIT signal using Ctrl + \ I get this output: # ./script.sh 6739 ^\./script.sh: ...
0
votes
0answers
59 views

Just how dangerous is sending SIGINT to resize2fs tasked with shrinking?

I inherited an old PC-server (quad Pentium 4) that only had partitions for /, /boot and swap (RAID1 with 2 1T SATA disks), but needed to update the distro (from CentOS 6.9). I decided to create a new ...
0
votes
0answers
17 views

Can a process directly wake up and deliver message to other process?

Can a process directly bring back other process's context to CPU and deliver message to that process, with things like interrupt? If the process, that I want to wake up and deliver message to, is ...
2
votes
0answers
69 views

A process is being stopped by SIGTTIN. Is there a good way of tracing what process (or kernel) sent this and why?

One of my Java processes is being stopped because it receives a SIGTTIN when processing a request. I can reproduce this issue. But I am unable to figure out why this is happening. I tried running ...
0
votes
2answers
80 views

Process Ignores Signals + Terminal/Shell Concept

I'm using linux kernel 4.1.8 32bit. My init process (using /etc/inittab and /etc/rd5.d Scripts) run the "Hello" process during boot time: int main(){ int val; printf("Hello\n"); scanf(...
0
votes
0answers
28 views

What signals to trap on for exec and exit of a program?

I'm attempting to print the name of the programm running in a shell session to the X-window title. As such, I have this working as follows: if [[ "$TERM" == *"xterm"* ]]; then trap 'printf "\033]...
1
vote
1answer
177 views

Can a process adopt a grandchild as its child?

Can a process pass the ownership of its children to its parent? Background Assume we have 3 processes: Grandparent, parent and child. Parent spawns child and lives on (parent does not die). ...
0
votes
0answers
37 views

Is SIGCHLD guaranteed to be delivered before wait() finishes?

I need to wait (in a blocking way) until child handler is executed after calling kill(child_pid, SIGTERM); in a program. Can waitpid() be used to determine this reliably? That is, is it guaranteed ...
4
votes
1answer
53 views

Restore interactive commands after accidentally overpaging pipe input to less?

Consider a script like this: $ cat example.sh #! /usr/bin/env bash for i in {1..90} do printf '%s\n' "$i" done sleep 10 printf '91\n' sleep 10 printf 'done\n' and suppose the output is piped to ...
1
vote
0answers
54 views

Unblock signals using standard utilities

How can I unblock signals in bash using standard utilities? In the past few weeks, I've noticed shells on macos hanging (eg, yes | head does not terminate). Digging in, it appears that all new ...
-1
votes
1answer
32 views

take action once background script is killed

I have below script running as background process. #!/bin/sh while true; do : done email_kill_alert() { echo "" | mailx -s "scritp received kill signal." emailid } Above script is run as background ...
0
votes
0answers
38 views

How to listen to other process' signals?

I'd like to know if it is possible, and if yes how, to listen to a specific process' signals. To explain a bit more the context: I have several critical processes running on a server and would like to ...
0
votes
1answer
35 views

How does KDE Konsole handle a SIGTERM?

I have a particular setup: One manager program can launch and stop a program. One wrapper program which is composed of: Konsole. One program worker running into Konsole. My problem is: When ...
1
vote
1answer
167 views

Why below code is not able to unblock SIGINT signal

I am trying my hand on Linux Signals. Where I have created a scenario mentioned below: Initially block all SIGINT signals using sigprocmask(). If sender send SIGUSR1 signal then unblock SIGINT for ...
-1
votes
1answer
69 views

How to break down signal system call prototype in Linux?

I am reading "The Linux Programming Interface", where I find signal system call prototype as stated: #include <signal.h> void ( *signal(int sig, void (*handler)(int)) ) (int); What is signal ...
1
vote
1answer
29 views

Screen signal main terminal that it's finished and closed

Referring to here about running script in screen session in the background and closes itself. screen -dmS myscreen bash -c 'command1; command2;' How can we signal the main terminal that the screen ...
1
vote
0answers
122 views

systemd sends SIGTERM twice when stopping a service

I have a C++ program that is being called by a systemd service. The program is not immediately called, but is nested in other scripts that are detached with '&'. When I stop the service the ...
1
vote
0answers
32 views

Create core dump only when a systemd service dies with a specific signal (segmentation fault)

I have some services running in systemd on Ubuntu 18.04 which very occasionally crash with a segfault (11/SIGSEGV). Is it possible to configure it to create a core dump only for SIGSEGV and not when ...
0
votes
0answers
30 views

How to write a script that sends kill signals if a process can't finish in s time? [duplicate]

I can't find any solutions for this problem anywhere. How to write a script that waits a process to finish, but if that process can't finish within s seconds, the script will send a signal TERM to ...
1
vote
0answers
61 views

How is an unprivileged terminal able to signal interrupt to a process launched via sudo as another user?

See for yourself: % sudo sleep 100 & [1] 23272 % pkill sleep pkill: killing pid 23275 failed: Operation not permitted % fg [1] + running sudo sleep 100 ^C % How is it that the terminal is ...
2
votes
0answers
132 views

Disabling “some” traps temporarily, and re-enabling them

I need to disable some(not all) of the traps temporarily in my function and then re-activate them. But I get an unexpected behaviour(I'm pretty new to traps and signals though) when I'm doing it: ...
16
votes
4answers
3k views

Why should fork() have been designed to return a file descriptor?

On his web page about the self-pipe trick, Dan Bernstein explains a race condition with select() and signals, offers a workaround and concludes that Of course, the Right Thing would be to have fork(...
1
vote
1answer
2k views

Why is command line program killed by SIGABRT?

I've been using a command line program (installed via package manager) that was working fine until I used vim to inadvertently insert a null byte (^@) in one of the program's data files when doing ...
0
votes
0answers
58 views

How to portably test for a SIGPIPE failure

In a bash script, I have a pipeline of this form /bin/find ... | grep --quiet --max-count=1 . Basically, I am just testing, yes/no, whether /bin/find found anything. Therefore, if /bin/find fails ...
1
vote
2answers
429 views

sleep system call on Linux - interaction with signals

I have a question about the documentation of sleep, on Linux OS. man 3 sleep says: regarding thread safety, sleep() is "MT-Unsafe sig:SIGCHLD/linux", which means that on Linux sleep() may ...
4
votes
2answers
128 views

edit-and-execute-command interrupted by SIGTSTP

I've been using bash's edit-and-execute-command function: edit-and-execute-command (C-x C-e) Invoke an editor on the current command line, and execute the result as shell commands. Bash ...
2
votes
1answer
434 views

Does Linux sends `SIGCHLD` to `init` when it inherits orphaned zombie processes?

Does Linux sends SIGCHLD to init (PID 1 process) when it inherits orphaned zombie processes (processes that have not been reaped by its original parent)?
0
votes
0answers
38 views

The shopt `huponexit` and processes ran as another user

The shopt huponexit defaults to off, but if enabled, it causes foreground, background, and stopped processes to be sent the HUP signal when the shell exits. Does this setting affect processes ran as ...
3
votes
2answers
415 views

EXIT Trap with POSIX

I have a script I wrote in Bash that I'm trying to modify to be POSIX-compliant. I have managed to get everything working except I cannot get the EXIT trap to trigger when the process is terminated ...

1
2 3 4 5
10