sigterm

ActiveRecord::StatementInvalid when process receives SIGTERM?

In my Rails app, I have a script that updates some records in the database. When I send a SIGTERM to kill the script, it occasionally receives that signal while ActiveRecord is executing a query. This leads to an ActiveRecord::StatementInvalid exception being raised. I'd like to catch StatementInvalid exceptions that occur when they...

In what order should I send signals to gracefully shutdown processes?

In a comment on this answer of another question, the commenter says: don’t use kill -9 unless absolutely necessary! SIGKILL can’t be trapped so the killed program can’t run any shutdown routines to e.g. erase temporary files. First try HUP (1), then INT (2), then QUIT (3) I agree in principle about SIGKILL, but the rest i...

How to free dynamic allocated variable by SIGTERM?

Hi, I work on code something like this ... HEADERS ... int *var; void child() { ... //some work free(var); exit(EXIT_SUCCESSFUL); } int main(void) { ... //allocate variable var = (int *) malloc(N*sizeof(int)); ... //work with var for(int i; i<PROC_COUNT; i++) { pid_t child = fork(); if(pid == 0) { child...

shell script to spawn processes, terminate children on SIGTERM

I want to write a shell script that spawns several long-running processes in the background, then hangs around. Upon receiving SIGTERM, I want all the subprocesses to terminate as well. Basically, I want a "master process". Here's what I got so far: #!/bin/sh sleep 600 & PID1="$!" sleep 600 & PID2="$!" # supposedly this should kill...

Win32 API analog of sending/catching SIGTERM

Under POSIX OS there is signal API that allows to send a signal to process to shut it down with kill and you can catch it with sigaction and do what you need; However, Win32 is not POSIX system, so: How can I handle shutdown events that may come, for example from "End Process" in "Task manager"? What is the standard API for sending sh...

Apache server keeps crashing, "caught SIGTERM, shutting down"

This just started happening three weeks or so ago. The content of my website hasn't changed, it's just a phpBB forum using MySQL as a backend. Nothing has changed in well over a year but recently, every two days or so, the server just shuts down and cannot be accessed at all, I have to notify my service provider to physically restart...

Is there a posix SIGTERM alternative on Windows? - (A gentle kill for console application)

I have a console deamon that is runned by a GUI application. When the GUI application is terminated I'd like to stop the deamon as well. How can I do it in a gentle way on windows? On Linux I would just use SIGTERM is there a similar mechanism on windows for console applications? To provide a bit more details: the deamon app is writte...

PID files hanging around for daemons after server restart

I have some daemons that use PID files to prevent parallel execution of my program. I have set up a signal handler to trap SIGTERM and do the necessary clean-up including the PID file. This works great when I test using "kill -s SIGTERM #PID". However, when I reboot the server the PID files are still hanging around preventing start-up...

Detect user logout / shutdown in Python / GTK under Linux - SIGTERM/HUP not received

OK this is presumably a hard one, I've got an pyGTK application that has random crashes due to X Window errors that I can't catch/control. So I created a wrapper that restarts the app as soon as it detects a crash, now comes the problem, when the user logs out or shuts down the system, the app exits with status 1. But on some X errors i...

How to detect pending system shutdown on Linux?

Hi, I am working on an app where I need to detect system shutdown. However, I have not found any reliable way get a notification on this event. I know that on shutdown, my app will receive a SIGTERM signal followed by a SIGKILL. What I want to know is if there is someway to query if a SIGTERM is part of a shutdown sequence? Does any one ...

how can I kill a Linux process in java with SIGKILL Process.destroy() does SIGTERM

In Linux when I run the destroy function on java.lang.Process object (Which is true typed java.lang.UNIXProcess ) it sends a SIGTERM signal to process, is there a way to kill it with SIGKILL? ...

Java: How to handle a SIGTERM

No many words needed: Is there a way in Java to handle a received SIGTERM? ...

I have a problem with the WIFSIGNALED()/WTERMSIG() macros, after using waitpid()

In this code C i launch a program from the command line and when it is closed from a signal different from SIGTERM (signal for normal end) my code should relaunch the initial program passed from the command line. But it is not so, in fact my code never relaunchs program saying that it is properly terminated.In practice my condition"if(WT...

'SIGTERM' problem.

Hi, I have this problem that when there is an OpenGL application I am working on. When I try drawing this particular piece of code: for (float i = 0; i < 100; i++) { glBegin(GL_LINE_LOOP); glVertex3f(cos(i), i, -10.0f); } glEnd(); I get this problem where the program crashes and returns: “SIGTERM” Any suggestions to he...