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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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.

-1
votes
0answers
20 views

how to (externally) continue running an app being debugged? is it possible at all?

I am running an app thru nemiver that runs gdb and finally the app. I need to automatically (in a delayed loop) read the files generated by that app, but for that I need to stop the app to prevent it ...
0
votes
0answers
30 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
12 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
31 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
35 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 ...
0
votes
2answers
124 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
20 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
25 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
29 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
38 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
43 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
55 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
2answers
74 views

How can I 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
51 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
344 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
23 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
31 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
81 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
112 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
73 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
145 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
188 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
50 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
79 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
34 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
73 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 ...
2
votes
1answer
181 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
108 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
247 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
83 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
91 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
178 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
44 views

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

Which signal can't be overridden in linux?
0
votes
1answer
250 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
29 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
92 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
36 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
407 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
34 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
36 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 ...
0
votes
1answer
50 views

Process continues to run after receiving uncaught SIGINT (Ctrl-C from terminal)

I am trying to interrupt some running processes with Ctrl-C from the terminal in Centos7; some do, some don't. One of the problematic processes (Process-A) is a GNU makefile with nothing fancy; just ...
0
votes
0answers
69 views

Listen for child process creation/fork

Say I have a process like so: #!/usr/bin/env bash node foo.js & pid=$! is there a way to listen to child processes that get created from pid? I want to create a list of pids that get created/...
0
votes
1answer
75 views

How can I make `enscript` block till the printer finishes its job?

The following command will create a pdf file under ~/PDF/: enscript -B -P PDF bloom.c I want to move the output pdf file here ...
0
votes
1answer
53 views

What are potential reason where linux send SIGINT SIGTERM or SIGHUP to a python script that is not user initiated?

I am seeing that my python script in ec2 linux getting terminated for some reason. I am not sure why and how to debug it. I tried sending the output of nohup to a file nohup python my_script.py >...
1
vote
1answer
508 views

Illegal instruction (core dumped) after running executable

I have two PCs (PC1 and PC2) running Linux Mint 18. I compiled a repository and had built an executable on one PC1, and it ran with no problem. I installed Linux Mint 18 on the other PC2, and tried ...