Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
1answer
33 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
13 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
55 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 ...
0
votes
0answers
45 views

How to send CTRL+c special char to interactive bash over tcp socket?

I use interactive bash shell over TCP network, but can't figure out how to send CTRL+c sequence to the remote bash. I first run netcat instance (this is where I interact with remote bash): nc -nvlp ...
0
votes
1answer
66 views

find command killed by signal 15

I have a problem regarding the find command: I use this line in a script to run around 300 servers and check if a file is present, returns 0 if the file is there and returns 1 if the file is not. $(...
2
votes
2answers
101 views

Bash ignoring SIGINT trap when 'select' loop is running

When i use 'trap' combined with select loop, namely when i try to hit CTRL+C to break out while options are displayed, it will just print ^C in terminal. If i remove 'trap' from script it will ...
0
votes
0answers
32 views

trap signal in bash initramfs fails to work

inside /init bash script executed by the kernel in initramfs.img i need to send a signal to drop me to a rescue shell, so i have trap "exec /bin/bash" SIGINT but ctrl+C isn't effective. First why ...
0
votes
0answers
28 views

SIGSEGV on dlopen with gdb

I'm currently building a shared library. The goal is to inject this lib in a process. Unfortunaly when I inject this lib in the process I get a SIGESGV about ostream. Here is a MWE to reproduce the ...
0
votes
0answers
39 views

What's the implementation of system call interruption? Why system call can be interrupted by signals? [duplicate]

As I have read from the book Computer Science: from A Programmer's Perspective, received signals are handled at the moment process shifts from kernel mode to user mode, usually returning from a system ...
2
votes
1answer
38 views

Two(≥2) signal handlers execution order when one is interrupted by another?

Suppose in main I register 2 signal handlers for SIGUSR1 and SIGUR2, let's say sig_ur1 and sig_ur2. What's gonna happen when signal SIGUR2 arrives when sig_ur1 is running? sig_ur1 running ----> ...
2
votes
2answers
41 views

Stopped process vs running service?

I stopped httpd processes on a centos 7.6 machine using kill -STOP command and the processes show up as stopped in top output. I tried to telnet the webserver's IP on port 80 and was able to do so ...
1
vote
2answers
678 views

What is interrupted system call?

I am reading APUE and the Interrupted System Calls chapter confuses me. I would like to write down my understanding based on the book, please correct me. A characteristic of earlier UNIX systems ...
0
votes
1answer
24 views

All processes seem to be ignoring certain signals

A couple of cloud servers we recently provisioned seem to ignore signals by default. I can figure out what has been configured to cause this behaviour and it is affecting both ctrl+c and bash scripts ...
0
votes
1answer
31 views

Bash multiple commands via `-c` parameter weird signal behavior?

bash -c "sleep 5; echo 'test'" If I run the above, and press CTRL-C while in the sleep 5, it terminates the entire process and echo 'test' does NOT get shown. How can I have the above run and allow ...
1
vote
0answers
32 views

Why do system calls need to be restarted after they receive a signal?

When a process receives a signal and the signal is handled the process doesn’t restart, from my understanding the only that need to be restablished is the signal handler.
-1
votes
1answer
46 views

How to capture a signal from user input? [closed]

I am trying to write a program to ask the user to enter the signal Number and then it will call a handler. #include <stdio.h> #include <signal.h> #include <unistd.h> void decide(...
1
vote
1answer
50 views

Signal trap from background job without pressing enter

In Bash 5 I ran into a situation where I want to do the following: trap 'echo trapped!' USR1 while true; do kill -SIGUSR1 $$; sleep 1; done & But I have to press enter on keyboard every time the ...
0
votes
0answers
69 views

how Ctrl + C is working inside the shell

I am reading about interrupts and signals and have problem with understanding the following scenario. Suppose the shell executing some command, then the shell process doing fork() + wait() ...
2
votes
3answers
177 views

How to signal a trap in “global” bash scope from function?

I want to execute a trap command in "global" scope, but the signal will come from within function. Of course it is possible to declare the variable globally beforehand or use the -g declare option. ...
0
votes
1answer
83 views

how signals are handled in linux kernel [closed]

My question is about signals and handling them inside the operating system kernel. I know that every process has it own signal_handler() table: a 31 bit array for signals (pending_signals), and when a ...
3
votes
1answer
481 views

What signal is sent to running programs / scripts on shutdown?

Right now I have the following: # this function is meant for future script expansions # its purpose is clear, i.e. to clean up some temp files # now, it is doing nothing, just a special null command ...
1
vote
1answer
25 views

Behavior of directly vs indirectly backgrounded children on read

When I do ( sleep 1; read x ; echo x=$x; echo done ) & then with the default terminal settings, the job gets stopped by SIGTTIN. If I do ( ( sleep 1; read x ; echo x=$x; echo done ) & ) ...
2
votes
0answers
36 views

How to trigger a command after named pipe closes?

How can I execute some command after the named pipe has been readout in other end. I was trying to use trap. But nothing happens. My script is something like below. #!/bin/sh cleanup() { echo "...
0
votes
0answers
33 views

Can I safely reduce CPU usage with kill -SIGSTOP?

I have 7 differents workspaces and each of them have a different purpose. But everything runs in the background... For exemple the workspace 5 with my browser is using CPU even when I'm on workspace ...
2
votes
1answer
91 views

Why doesn't ctrl+u send SIGKILL? stty says it should

I can interrupt a program by pressing ctrl+c in the shell. Often this kills the program but some programs trap the signal and keep running. I want to be able to kill such programs more aggressively ...
-2
votes
2answers
49 views

Does an interactive bash process implicitly send any signal other than SIGHUP to its job?

Does an interactive bash process implicitly send any signal other than SIGHUP to its job? By implicitly, I mean not as a consequence of a user's request to send a signal to a job. It helps to answer ...
1
vote
3answers
142 views

Why does closing terminal emulator window terminate a bash process with SIGHUP trap changed not to terminate?

In a bash shell in a terminal emulator window of lxterminal, I run $ trap "echo hello" SIGHUP $ kill -s HUP $$ hello $ and then I close the terminal emulator window. Does closing the terminal ...
3
votes
1answer
92 views

Does ` (sleep 123 &)` remove the process group from bash's job control?

Does the following way $ (sleep 123 &) $ jobs $ remove the process group of sleep 123 from bash's job control? What is the difference between the above way and disown then? Note that the sleep ...
-2
votes
1answer
180 views

Why doesn't the Linux kernel send SIGCONT first and then SIGHUP to a newly orphaned process group containing a stopped process?

APUE says Since the process group is orphaned when the parent terminates, and the process group contains a stopped process, POSIX.1 requires that every process in the newly ...
5
votes
1answer
200 views

Why do we need to send SIGHUP to a newly orphaned process group containing a stopped process?

The Advanced Programming in the UNIX Environment book ("APUE") says Consider a process that forks a child and then terminates. Although this is nothing abnormal (it happens all the time), ...
0
votes
0answers
58 views

Is it possible to distinguish signal from kernel at reboot and at kill from terminal

As I know, we can send a signal SIGTERM to a process by pressing ctrl+c or by using pkill -f processName. Also, when we reboot or shutdown, the kernel will send SIGTERM to each process too. So I'm ...
-8
votes
1answer
107 views

How can we tell if a signal can interrupt the execution of a system call?

From The Linux Programming Interface a signal is delivered at one of the following times: when the process is rescheduled after it earlier timed out (i.e., at the start of a time slice); or ...
-2
votes
1answer
46 views

How is “some other pending, unblocked signal” involved when a process sends a signal to itself?

Advanced Programming Unix Environment says: #include <signal.h> int kill(pid_t pid, int signo); ... If the call to kill causes the signal to be generated for the calling process ...
-1
votes
1answer
110 views

How is `SIGSEGV` an example of “signals related to the current state of the process be delivered before other signals”? [closed]

APUE says What happens if more than one signal is ready to be delivered to a process? POSIX.1 does not specify the order in which the signals are delivered to the ...
3
votes
1answer
239 views

What is a fatal signal?

The Linux Programming Interface says: TASK_KILLABLE : This state is like TASK_UNINTERRUPTIBLE , but wakes the process if a fatal signal (i.e., one that would kill the process) is received. By ...
0
votes
2answers
140 views

Does the default action of SIGCONT resume the execution of a stopped process before or after first handling any pending unblocked signals?

http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04 says: The default action for SIGCONT is to resume execution at the point where the process was stopped, after ...
5
votes
2answers
343 views

What processes can survive logging out of Linux, and what not?

I am trying to understand what happens when we log out of Linux (Ubuntu specifically): How does a process initially request/notify the logging out process to perform logging out (by sending some ...
2
votes
2answers
90 views

Catch which user sends kill signal

Say I'm running some script that just sleeps, and another user with admin rights tries to kill my script using pkill. How can I catch which user sent that signal to my process, if such a thing is ...
1
vote
0answers
136 views

Resize window in multi-thread ncurses program

The overall question is simple: How to gracefully resize a window in a multi-thread ncurses program? Details here. I have read a few relevant questions (1, 2, 3). From my understanding, there are ...
8
votes
4answers
1k views

Why does the kernel even bother to send SIGKILL? [duplicate]

If a program is not allowed to handle or ignore SIGKILL and SIGSTOP, and must immediately terminate, why does the kernel even send the signal to the program? Can't the kernel simply evict the program ...
0
votes
0answers
232 views

Cannot pass argument through /proc/<pid>/fd/0

I have written a basic C++ program as such: #include <sstream> #include <unistd.h> #include <cstdio> #include <iostream> int main(void) { int foo; std::cin >> foo; ...
-6
votes
1answer
45 views

A signal that can't be overridden? [duplicate]

Which signal can't be overridden in linux?
0
votes
1answer
382 views

Must SIGKILL (and SIGTERM) be explicitly sent to a specified process?

Reading Gilles' answer, SIGHUP is about the same as SIGTERM in terms of harshness, but it has a specific role because it's automatically sent to applications running in a terminal when the user ...
1
vote
1answer
40 views

After Receiving an signal, which exception handler invoked first?

Let's say we have a program in C that uses the sleep() function. The program executes and goes to sleep. Then we type ctrl-c to send a SIGINT signal to the process. We know that the default action ...
1
vote
1answer
230 views

Process started by script does not receive SIGINT

I am on Ubuntu 16.04.5 LTS (AWS) I am creating a python process via this command: nohup python -u main.py > nohup.out 2>&1 & I would like to send a ctrl-c/SIGINT to the process, so I ...
1
vote
1answer
46 views

Is it possible to determine the signal received by last running application?

From a shell, say Bash, is it possible to retrieve the signal number received by the application that most recently finished, if any, in a way that is similar to checking the return code of a process ...
0
votes
1answer
23 views

How to minimize resource usage while process waits to be killed by a signal?

My C++ program does some work, and then waits for a signal to kill it. I'd like to just exit, but exiting sends SIGCHLD to parent process, and I need to control the timing of that. So currently I do ...
0
votes
1answer
601 views

Is it safe to send SIGUSR1 to a program, and why? [closed]

When you send SIGUSR1 signal (say the signal handler has been set in advance) to a program while it is executing sleep(100), the signal is caught correctly but sleep(100) is terminated just after the ...
0
votes
1answer
41 views

Email sent to root: “Output from from your job 1843” - “Killed”

I run a Sheevaplug (small ARM server) with Debian 9. It does not have any third-party repos enabled in sources.list / sources.list.d. I have a backup script which runs as root, and uses at. I think ...
2
votes
1answer
46 views

What are some other reasons for process being in D state except performing I/O?

I have been recently asked this question during interview, "What is D state and when does process goes in D state. I explained what D state is and then gave the answer that when the process is ...