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.

1
vote
1answer
32 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 ...
-4
votes
0answers
40 views

When a bash process is running in a pseudo-terminal, what will happen when we hit Ctrl-D? [duplicate]

When we hit some key for terminal related signal, such as Ctrl-C, is it correct that it will directly trigger the kernel to send a signal to the foreground process group for the current controlling ...
0
votes
0answers
48 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
44 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
46 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
283 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
21 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
33 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
27 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
72 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
93 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
61 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
97 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 ...
0
votes
0answers
28 views

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

APUE says Consider a process that forks a child and then terminates. Although this is nothing abnormal (it happens all the time), what happens if the child is stopped (using job ...
0
votes
0answers
43 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 ...
-7
votes
1answer
64 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
31 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
65 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
122 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
61 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 ...
4
votes
2answers
188 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
71 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
41 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
897 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
108 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
165 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
25 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
47 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
34 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
21 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
202 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
26 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
35 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
41 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
52 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
65 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
36 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
248 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 ...
-1
votes
3answers
247 views

How to send SIGINT to multiple processes

I am trying to send the SIGINT signal to multiple processes, I think this is right: kill -2 <pid1> <pid2> ... <pid3> but I cannot confirm that...
1
vote
2answers
46 views

Why application does not run from SCREEN without delay?

Suppose we need to run application in screen and keep it running when screen exits. The following command does the job, but only if "sleep 1" is appended to it. Why it does not work without "sleep 1"? ...
3
votes
1answer
99 views

Why do strace and ltrace cause EINTR to happen?

Consider this program: #include <stdio.h> #include <sys/epoll.h> int main(void) { int epfd = epoll_create1(0); struct epoll_event event; event.events = EPOLLIN; ...
-1
votes
1answer
50 views

Terminal that sends CTRL+C to tty, when I click CTRL+B

I use Linux Mint with 'Terminal GNOME'. I want to use CTRL+C in terminal to copy text. Easy.. I set it in Preferences, but I also need to send somehow 'intr' signal to apps. I want to make terminal ...
2
votes
1answer
59 views

Script error handling: need to report segfault in script run by ssh

I wrote a cron job, which uses ssh to run a script on a server. I just tried running the script, and now I am unhappy. client# ssh server.local /usr/local/bin/script client# server# /usr/local/bin/...
-1
votes
2answers
79 views

Background process (postgresql) receiving SIGINT from Ctrl-C in shell

I wrote a shell.nix file to build the development environment for one of my projects. I'm using a shellHook to ensure a postgresql server is started when you drop into the nix-shell. The shellHook is ...
0
votes
0answers
135 views

How to properly handle SIGINT for both the interactive and non-interactive Bash scripts?

Backgound I have read a post about handling of SIGINT signal, but I still don't understand how to properly handle it in code which will be sourced and used by both the interactive and non-interactive ...
2
votes
1answer
235 views

How does systemd stop services that don't have a unit file

Systemd can inherit orphaned processes, and there are other ways a service can be running without having a unit file for the given service. I want to know what the catch-all is for services that don'...
2
votes
1answer
111 views

How to trap INT signal infinitely many times?

I'm piping output of an interactive command (ghci) through sed-based script to add some colors: ghci | colorize.sh where colorize.sh is something like: #!/bin/bash trap '' INT sed '...some pattern.....
1
vote
1answer
131 views

Set signal mask of child process in Bash

Here's my problem - I'm trying to write a small wrapper script that adds a command line argument when Xorg is called (I don't have access to the caller's source.) It seemed simple enough, but the ...