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
0answers
35 views

Can a file descriptor ready for IO become unready before any IO operation is performed on it?

In The Linux Programming Interface, on p1327 in 63.1 Overview of 63 Alternative Models In effect, I/O multiplexing, signal-driven I/O, and epoll are all methods of achiev- ing the same result—...
0
votes
1answer
39 views

Why does SIGINT not terminate a stopped process?

According to the POSIX standard regarding signals (see "Standard signals" section), both SIGKILL and SIGINT have as default action Term. However, this seems not to be the case when the ...
-1
votes
1answer
23 views

Send signal to paused parent process and guarantee that it will arrive AFTER the parent pauses

I have this kind of pseudo-code and i'm wishing to know what I must change in order to guarantee that the signal send to the parent will indeed arrive after that the parent pauses. int main() { ...
-2
votes
3answers
91 views

What is the relation between SIGCHLD and `waitpid()` or`wait()`?

If I am correct, a process waits for its children to terminate or stop by calling the waitpid() or wait() function. What is the relation between SIGCHLD signal and the waitpid() orwait() functions? ...
0
votes
2answers
128 views

Difference between kill <pid> and kill -s TERM <pid>

What exactly is the difference between kill <pid> and kill -s TERM <pid>. Initially i thought the $TERM variable holds a signal number but when I echo TERM its gives me $echo $TERM xterm-...
0
votes
1answer
40 views

Does the kernel by default block pending signals when the process is in kernel mode?

Computer Systems: a Programmer's Perspective says: 8.5.1 Signal Terminology A pending signal is received at most once. For each process, the kernel main- tains the set of pending signals in the ...
4
votes
0answers
46 views

Why does ZSH finish executing a function after exit was called from a trap?

Consider the following script: trap "echo TRAPPEDTERM >&2; exit" TERM termself () { kill -TERM $$ echo "Survived TERM!" } termself echo "Bye." Executed ...
1
vote
1answer
25 views

Why if I change the name of procps's kill command (mv /usr/bin/kill /usr/bin/anotherkill) in Ubuntu 20.04, it stops working?

For instance, if I run anotherkill -s 9 1234, I get this error message: skill: "anotherkill" is not supported For more details see skill(1). Above referenced man page doesn't help, however. ...
1
vote
1answer
54 views

What is the difference between `Ctrl + C` and `kill -2` command sending a signal using?

For example, while I am running the script below, if I send an INT signal with Ctrl + C, the script file gets interrupted immediately. But when I try the same process with the kill command as kill -2 ...
1
vote
1answer
24 views

Disable energy saving settings completely? HDMI signal lost (DPMS and screensaver already disabled)

On my MX Linux XFCE environment I have the problem that after a certain time without interaction after power on the HDMI signal is lost and can only be retrieved with pressing a keyboard key. I would ...
2
votes
1answer
55 views

How to trap EXIT unconditionally (even if interrupted), in Zsh?

I would like to trap the exit hook of a function. Bash provides a nice signal called RETURN (non-POSIX) which get called when a function returns, such as function test_trap() { trap 'echo trapped' ...
1
vote
1answer
29 views

Child shell script didn't respond to terminal interrupt sent to the foreground process group

I have a master script that controls some satellite scripts. When I send the interrupt signal from the terminal, the parent's traps caught the signal, but the child's didn't, which I can't figure out ...
0
votes
1answer
68 views

sigaction() sa_flags and POSIX.1-2001 Base Spec

This is an excerpt from SIGACTION(2): POSIX.1-1990 specified only SA_NOCLDSTOP. POSIX.1-2001 added SA_NOCLDSTOP, SA_NOCLDWAIT, SA_NODEFER, SA_ONSTACK, SA_RESETHAND, SA_RESTART, and ...
1
vote
0answers
51 views

Send SIGINT to a command launched inside bash script

I am executing a bash script and I want to correctly terminate a command (by pressing CTRL+C) that I am launching inside the script. This is the script: trap ctrl_c SIGINT function ctrl_c() { PID = $!...
0
votes
1answer
32 views

can read system call experience short count after it is interrupted by a signal?

Let's say I call read to read 1000 bytes, and when read is reading the 501th bytes then a signal interrupts it, so does read return 500?
0
votes
1answer
52 views

Is it safe to restart system calls?

I was reading a textbook which describes how to deal with system call when interrupted: System calls can be interrupted. System calls such as read, wait, and accept that can potentially block the ...
0
votes
0answers
44 views

Trapping argument not working on SIGTSTP in bash script

Trapping argument not working on SIGTSTP in bash script. When the Ctrl + C shortcut generates the INT signal, the "echo Ctrl + C detected!" command that I gave as an argument to the trap ...
-1
votes
2answers
151 views

Why printf is not asyc signal safe function?

We know that printf is not async signal safe function. And below is my basic understanding: Let's say we have called printf in main method, so the content is written to stdio buffer, just before the ...
1
vote
1answer
72 views

Call only async-signal-safe functions in signal handlers? [closed]

I'm new to signal and signal handler and I was reading a book which says Call only async-signal-safe functions in your handlers. A function that is async-signal-safe, or simply safe, has the property ...
-3
votes
1answer
45 views

what does 'proc' in 'sigprocmask' mean?

I'm new to Linux and signals, sorry if my question sounds dumb, we know that Applications can explicitly block and unblock selected signals using the sigprocmask function, but what does 'proc' stand ...
1
vote
2answers
79 views

How make CTRL-C work in command line when it does not?

I'm struggling with not working CTRL+C in a certain environment shell command line (CentOS 7 / Vagrant guest of Windows host). I use bash there. The OS, seem, does not matter. Example run sleep 1000 ...
0
votes
2answers
55 views

Is the sigspec for 0 EXIT or SIGEXIT or exit?

I need to write a trap which tracks when a process exits (amongst other things) and removes a temporary file. I'd prefer to use the sigspec instead of number for better code readability, the relevant ...
0
votes
0answers
49 views

why does one trapped signal cause another to repeat?

Here is my script: #!/bin/bash # this is repeat-signal.sh trap "echo got USR1; wait" USR1 trap "echo got INT" INT ( kill -s USR1 $$ sleep 100 ) & wait When I run this ...
0
votes
0answers
20 views

SIGSTOP anything I haven't interacted with in 10 minutes?

For working on multiple projects, I may open several applications in separate workspaces. It's possible that while I'm working on one thing, the other set of applications are open but not in use. I ...
1
vote
1answer
54 views

Trap SIGPIPE upon writing to FIFO

These are the steps to reproduce the problem. writer: #!/bin/bash trap 'echo NoReader!' PIPE cat > fifo Open two terminals. I will denote them by the >T1< and >T2< headers below, and ...
0
votes
1answer
429 views

How do I use sigaction() with SA_RESTART correctly?

I want to develop a C code that will wait concurrently for both keyboard input and keyboard-generated signals, and will be able to have other I/O (with pipes and files) active. I have a minimal signal ...
0
votes
1answer
77 views

End process but resume bash script?

I am trying to create a script in which part of it runs a command that can only be stopped by the user sending SIGINT to the process. I want the user to be able to press Ctrl+C to end that part of the ...
0
votes
0answers
51 views

Does wait work without SIGCHLD?

I have a parent process that runs a child process and then wait for it: myprocess & wait $! However, when myprocess exits, the parent process continues waiting for it. After listing the signals ...
2
votes
3answers
93 views

Pause and resume application

I can pause and resume a process by sending it the SIGSTOP and SIGCONT signals. Taking Firefox as an example: pkill --signal SIGSTOP firefox pkill --signal SIGCONT firefox The thing is that Firefox ...
0
votes
1answer
39 views

Are socketpairs useable as signal-safe buffers?

I am thinking on a way of communication between signal handlers and the main program. Note, I use mosly non-blocking signals (a new signal can arrive even while a signal handler is executed), so I am ...
2
votes
1answer
42 views

identify process sending a signal to a shell script

I've written a shell script that uses the trap feature to output its progress when it receives a SIGUSR1 signal, but I don't see how to have the script be able to output the progress to the STDOUT of ...
3
votes
1answer
95 views

What determines whether a script's background processes get a terminal's SIGINT signal?

#!/usr/bin/env bash sleep 3 && echo '123' & sleep 3 && echo '456' & sleep 3 && echo '999' & If I run this, and send SIGINT by pressing control-c via terminal, it ...
0
votes
0answers
26 views

Catch signal when a command fails

I'm trying to build a shell that gives you suggestions if you have a typing error, but I'm having trouble to catch the error. The user will type something and after parsing it, I will use the execvp() ...
2
votes
1answer
75 views

How can I prevent Ctrl+C from “going outwards”?

I want to run an interactive tool that can either exit by itself (when the tasks are done) or by me hitting Ctrl+C. In this example, the tool consists of an echo and a sleep (thus it is not really ...
0
votes
0answers
32 views

missing SIGINT from script?

I am experiencing very strange behaviour when I attempt to send SIGINT from a bash script: #!/bin/bash ./executable 6 & PID=$! sleep 2 kill -s SIGINT $PID sleep 2 if wait $PID; then echo "...
1
vote
1answer
91 views

Termination of ssh with Ctrl-C trap in bash script

When I press Ctrl+C with the first script, it works as I expect, Ctrl+C doesn't have any effect #!/bin/bash trap '' INT ssh user@server 'svn checkout ...' echo "done" But with the second script Ctrl+...
2
votes
1answer
143 views

What’s the difference between SIGALRM and SIGVTALRM?

I do understand that both are used to raise a signal according to the time elapsed… But what’s the difference then ? In my case, I want to raise such signal against specific thread time where the ...
1
vote
2answers
126 views

less stops my script; why is that and how to avoid?

I have this Bash script named as s in current directory: #!/bin/bash pipe_test() { ( set -m; ( $1 ); set +m ) | ( $2 ) } pipe_test "$1" "$2" If I call e.g. ./s yes ...
0
votes
1answer
35 views

How do linux syscalls implementations handle a caught signal?

I understand how signals work in general and I understand that syscalls are changing the task state to TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE to prevent signal interruption on critical sections. ...
0
votes
1answer
111 views

Why does grep return SIGPIPE (signal 13) here?

I have to create a program where i have P0 as parent process and P1,...,PN children processes. Every child has to perform grep in a file and return the output in a pipe. Then P0 has to read the ...
0
votes
0answers
88 views

Kill a hanging process which is in kernel mode

I had a process attached to a debugger session, and, by mistake, I kill the debugger. Now, I'm trying to kill the process I was debugging but I can't because it's probably in Kernel Mode now, maybe ...
2
votes
1answer
82 views

How come `while true; do echo y; done | true` dies on its own, but `while true; do echo y | cat; done | true` doesn't?

To be clear with the title question, I understand why the former dies. I don't understand why the latter doesn't, just for adding a | cat to the loop body. Also maybe related, while true; do echo y; ...
2
votes
1answer
246 views

Debugging sporadic 141 shell script errors

While running a script on CI (Gitlab, Docker container running Alpine Linux), I am getting sporadic failures with signal 141 which seems to indicate a "SIGPIPE". But I do not understand which step is ...
0
votes
1answer
90 views

File descriptor from `signalfd(2)` is never ready to read

I have a fairly big application under care. As part of its job it spawns some child processes and needs to monitor their state (running, crashed). Child process deaths were detected by setting signal ...
2
votes
1answer
268 views

Without nohup on csh, background job still running after ssh exits

I'm trying to understand the need for using nohup with background commands in ssh. My shell is csh on CentOS. The background command below continues running even after ssh exits. I was expecting this ...
0
votes
2answers
81 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
58 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 & ...
6
votes
1answer
2k 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
404 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 machine, ...
4
votes
1answer
266 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 ...

1
2 3 4 5
11