Sponsored Content
Top Forums Programming Reliable management of signal SIGPIPE and SIGTERM Post 302406226 by italian_boy on Monday 22nd of March 2010 10:27:26 AM
Old 03-22-2010
Reliable management of signal SIGPIPE and SIGTERM

I' m note very expert in the reliable manage of signal... but in my server I must manage SIGPIPE for the socket and SIGTERM...
I've wrote this but there is something wrong... Can someone explain me with some example the reliable management of signal??

This is what I've wrote in the server
Code:
 struct sigaction sig, osig; 
   sigset_t sigmask, oldmask, zeromask;

  sig.sa_handler= catcher;
  sigemptyset( &sig.sa_mask);
  sig.sa_flags= 0;
  sigemptyset( &sigmask);
  sigaddset(&sigmask, SIGPIPE);
  sigaddset(&sigmask, SIGTERM);
  sigprocmask(SIG_BLOCK, &sigmask, &oldmask);
  sigaction(SIGPIPE, &sig, &osig);
  sigaction(SIGTERM, &sig, &osig);

......
......
......
while(1){
.....
.....
......
.....
.....
sigsuspend(&zeromask);
}

....
.....
......
}

 

9 More Discussions You Might Find Interesting

1. Programming

signals - SIGTERM

Hi all, I need some urgent help. we are using Dynix/ptx V4.5 on i386, have several processes and instances are running on the box round the clock.we increased the processes recently. We have coded to handle the signals in our programs. Recently, we noticed most of our processes are... (2 Replies)
Discussion started by: reddyb
2 Replies

2. AIX

auditing fails with SIGPIPE signal on 1/4 hour

Hi folks, Can anyone assist with pointers for the following snag? We have custom method (IBM-supplied) for running the audit subsystem on 5.1-07 /etc/security/audit objects, events and config have been edited, and the /etc/security/audit/streamcmds contains the following routine; ... (1 Reply)
Discussion started by: reclspeak
1 Replies

3. Shell Programming and Scripting

How to detect SIGTERM,SIGKILL signal in UNIX

Dear All We have JBOSS server running on Linux we need to track Graceful Shutdown(SIGTERM) and Forceful Shutdown(SIGKILL) timestamp and write it into one file, I am new to UNIX Signal processing if is it possible how to detect it? We generally do $kill PID For Graceful... (5 Replies)
Discussion started by: mnmonu
5 Replies

4. Programming

Catch signal SIGPIPE print errno but it's value equal to 2

catch signal SIGPIPE ,print errno but it's value equal to 2(ENOENT) #define ENOENT 2 /* No such file or directory */ is it should be EPIPE ? #define EPIPE 32 /* Broken pipe */ Thanks ! (7 Replies)
Discussion started by: aobai
7 Replies

5. UNIX for Advanced & Expert Users

Why not SIGPIPE for readers of pipe/FIFO?

Hi This is a exercise question from Unix network programming vol2. Why the SIGPIPE signal is generated only for writers when readers disappear. why not it is generated for readers when writer disappears. I guess, if the writer didn't get any response like the reader gets EOF, it will... (4 Replies)
Discussion started by: kumaran_5555
4 Replies

6. Programming

SIGPIPE and EPIPE

When a write() writes on a broken pipe, with no readers, it generates a SIGPIPE signal and the process exits. When the write() returns -1 and errno is EPIPE? Do I have an handler for SIGPIPE, or can I ignore it? (2 Replies)
Discussion started by: hurricane
2 Replies

7. UNIX for Dummies Questions & Answers

Is this website reliable ?

edit by bakunin: content not relevant for our site (and bordering on spam) SNIPped, thread closed. My suggestion is to - before even considering to buy anything online - put more effort in research, i.e. what the web site you write a comment at, is all about. This one here is definitely not for... (1 Reply)
Discussion started by: ethansk
1 Replies

8. Homework & Coursework Questions

C TCP/IP Reliable Transmission project not reliable

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: We must do the following for a massive coding project that is due at 12:20PM on Monday, July 22, 2013. We are to... (1 Reply)
Discussion started by: kowit010
1 Replies

9. AIX

SIGTERM failing in AIX

I have 2 AIX 6.1 systems running on PowerPCs - production and .. .everything else. :p . Until the installation of a TLS certificate in an application, some copying of files ("cloning an environment") and upgrading a listener, sending a kill -15 worked on any script/application, so long as we were... (6 Replies)
Discussion started by: Mrucker
6 Replies
SYSTEMD.KILL(5) 						   systemd.kill 						   SYSTEMD.KILL(5)

NAME
systemd.kill - Process killing procedure configuration SYNOPSIS
service.service, socket.socket, mount.mount, swap.swap, scope.scope DESCRIPTION
Unit configuration files for services, sockets, mount points, swap devices and scopes share a subset of configuration options which define the killing procedure of processes belonging to the unit. This man page lists the configuration options shared by these five unit types. See systemd.unit(5) for the common options shared by all unit configuration files, and systemd.service(5), systemd.socket(5), systemd.swap(5), systemd.mount(5) and systemd.scope(5) for more information on the configuration file options specific to each unit type. The kill procedure configuration options are configured in the [Service], [Socket], [Mount] or [Swap] section, depending on the unit type. OPTIONS
KillMode= Specifies how processes of this unit shall be killed. One of control-group, process, mixed, none. If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=). If set to process, only the main process itself is killed. If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the unit's control group. If set to none, no process is killed. In this case, only the stop command will be executed on unit stop, but no process be killed otherwise. Processes remaining alive after stop are left in their control group and the control group continues to exist after stop unless it is empty. Processes will first be terminated via SIGTERM (unless the signal to send is changed via KillSignal=). Optionally, this is immediately followed by a SIGHUP (if enabled with SendSIGHUP=). If then, after a delay (configured via the TimeoutStopSec= option), processes still remain, the termination request is repeated with the SIGKILL signal (unless this is disabled via the SendSIGKILL= option). See kill(2) for more information. Defaults to control-group. KillSignal= Specifies which signal to use when killing a service. This controls the signal that is sent as first step of shutting down a unit (see above), and is usually followed by SIGKILL (see above and below). For a list of valid signals, see signal(7). Defaults to SIGTERM. Note that, right after sending the signal specified in this setting, systemd will always send SIGCONT, to ensure that even suspended tasks can be terminated cleanly. SendSIGHUP= Specifies whether to send SIGHUP to remaining processes immediately after sending the signal configured with KillSignal=. This is useful to indicate to shells and shell-like programs that their connection has been severed. Takes a boolean value. Defaults to "no". SendSIGKILL= Specifies whether to send SIGKILL to remaining processes after a timeout, if the normal shutdown procedure left processes of the service around. Takes a boolean value. Defaults to "yes". SEE ALSO
systemd(1), systemctl(1), journalctl(8), systemd.unit(5), systemd.service(5), systemd.socket(5), systemd.swap(5), systemd.mount(5), systemd.exec(5), systemd.directives(7), kill(2), signal(7) systemd 237 SYSTEMD.KILL(5)
All times are GMT -4. The time now is 02:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy