Stack Exchange Network

Stack Exchange network consists of 174 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.

7
votes
4answers
613 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 ...
-1
votes
0answers
35 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
40 views

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

Which signal can't be overridden in linux?
0
votes
1answer
50 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
21 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
23 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 ...
0
votes
0answers
34 views

How to kill a blocked process (for example, waiting for I/O)?

The signal SIGKILL can not kill the process that is waiting for I/O. And what if this process are waiting for a very long time, how can I kill this process?
1
vote
1answer
31 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
20 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
63 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
19 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 ...
0
votes
0answers
18 views

What happens in the kernel when an interrupt signal is sent to a process?

When I run a command that takes very long in terminal and want to kill it before it finishes, I press control-c to send an interrupt signal to the process. I'm assuming this signal is first picked up ...
2
votes
1answer
32 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
35 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
38 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
64 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
17 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
115 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
128 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
45 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
66 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
43 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
49 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
56 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
94 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
121 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
80 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
90 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 ...
2
votes
1answer
100 views

Can a Linux-process intercept signals sent to its child?

I have a shell-wrapper around a large executable. It does something like this: run/the/real/executable "$@" & PID=$! # perform # a few # minor things wait $PID # perform some # post-processing ...
3
votes
4answers
281 views

Delay termination of script

I have a script like this (written for /bin/sh on OpenBSD) which first updates a local copy of some CVS repositories using rsync, and then updates the checked-out version of these on my machine. The ...
1
vote
1answer
43 views

behavior of interrupt signal after forking

I used the following code while studying signals. #include<stdio.h> #include<sys/stat.h> #include<sys/wait.h> #include<unistd.h> #include<stdlib.h> #include<signal.h&...
1
vote
0answers
73 views

Prevent children to be stopped by SIGTERM

I wrote this script (I removed some useless stuff): #!/bin/bash readonly ARGS="$@" catch() { echo "Sigterm caught" # Perform some cleanup instructions # that suppose the child process ...
3
votes
2answers
166 views

How can we set up a signal trap to be SIG_IGN and SIG_DFL in bash?

From https://unix.stackexchange.com/a/447032/674 So in terms of code, assuming the SIGINT signal, these are the three options: signal(SIGINT, SIG_IGN); to ignore To not call the signal()...
0
votes
1answer
65 views

Do “caught” and “delivered” mean the same for a signal? [closed]

Do "caught" and "delivered" mean the same for a signal? In APUE, a signal is called delivered if it is started to be handled. The book uses "caught" in many places. I haven't found what it means by ...
0
votes
1answer
56 views

Choices for dealing with a signal?

From APUE A process has three choices for dealing with a signal. Ignore the signal. This option isn’t recommended for signals that denote a hardware exception, such as ...
1
vote
0answers
101 views

Where does a bash process get its default signal handlers/traps?

From https://stackoverflow.com/questions/50606753/do-getrlimit-and-setrlimit-work-by-reading-from-and-writing-to-etc-sec#comment88227414_50607042 Bash doesn't have a special handler for SIGQUIT ...
1
vote
1answer
48 views

When receiving SIGINT, does bash also quit other commands, besides loops (for or while)?

From bash manual When Bash receives a SIGINT, it breaks out of any executing loops. When receiving SIGINT, does bash also quit other commands, besides loops (for or while)? Thanks.
1
vote
0answers
152 views

Why does bash exit immediately when waiting for a command to complete and receives SIGHUP for which a trap has been set?

From Bash manual If Bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the command completes. When Bash is ...
0
votes
1answer
53 views

Could you explain the following statements on how nonbuiltin commands started by Bash handles signals?

From bash manual Non-builtin commands started by Bash have signal handlers set to the values inherited by the shell from its parent. When job control is not in eff ect, asynchronous ...
0
votes
1answer
51 views

Who sends SIGHUP to the controlling process of the pseudoterminal when the terminal emulator terminates?

When a terminal is disconnected, the OS kernel sends SIGHUP to the controlling process of the terminal. When a terminal emulator terminates, who sends SIGHUP to the controlling process of the ...
0
votes
1answer
433 views

Where is core dumped file by handling SIGQUIT stored?

From http://qr.ae/TUTxgN SIGQUIT is the dump core signal. The terminal sends it to the foreground process when the user presses ctrl-\. The default behavior is to terminate the process and dump ...
1
vote
2answers
97 views

What if all signal are ignored?

As far as I know, some signal is used to stop/continue and terminate/kill process. If I made the process ignore all the signal, what will happen? Will it be a zombie or something unable to be killed?
0
votes
0answers
51 views

`sg` command does not forward sigterm

When I run bash -c 'trap "echo TERM" SIGTERM; id;read' And send a SIGTERM to it, it simply echos TERM, however when I do sg docker "bash -c 'trap \"echo TERM\" SIGTERM; id;read'" The process ...
0
votes
2answers
40 views

Which signal >(process) receives after main shell exits?

This is a Zshell question, although Bash, if it has >(command) syntax (i.e. process substitution of such kind), can hint a solution too. This really basic code explains all: % fun() { setopt ...
0
votes
1answer
197 views

Why script that kill itself using a signal handler produce segmentation fault?

SCRIPT GOAL: the script is invoked as ./script.sh cmd1 cmd2 ... cmdn. It should executes in background all the commands passed as arguments from the command line and check when all of them have ...
0
votes
2answers
1k views

Why is kill -HUP used in logrotate in RHEL? Is it necessary in all cases?

I see for syslog logging, kill -HUP is used. /var/log/cron /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler { sharedscripts postrotate /bin/kill -HUP `cat /var/run/...
0
votes
0answers
84 views

help with kill command SIGKILL vs SIGTERM [duplicate]

there was a nice write up somewhere on here about... not using kill-9 all the time which is SIGKILL and explained the reasons for doing so, and then went on to explain an order in which one should ...
3
votes
0answers
90 views

What exactly in the sudo behavior is unpredictable?

In the Best practices for writing Dockerfiles guide of the docker documentation, we can read: Avoid installing or using sudo since it has unpredictable TTY and signal-forwarding behavior that can ...
0
votes
1answer
883 views

Custom systemd service fails with result 'signal' status=1/HUP

I have a Python script that restarts a GSM modem by opening its /dev/ttyUSBx serial port file, sending a shutdown AT-command, waiting for a response and then waiting for the modem to shutdown by ...
0
votes
1answer
229 views

Send SIGTERM to a suspended process

I have 2 processes written in c, I'll call them 'parent' and 'child'. Parent creates child and child enters a loop where it does some code, then raises SIGSTOP. If a certain condition is reached, the ...