Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Linux


Programming :: [C++] Cannot Catch SIGPIPE Signal?

I have a Socket library, written in C++, in which the method used to send data never has the opportunity to handle an errno of SIGPIPE. Thus I thought perhaps I should setup a signal handler to receive the signal, but this too is not being called.Is there something that I am missing or doing that is completely wrong? Below is the relevant code. Note that a SIGPIPE signal is generated when the Server is unable to send data to the Client (e.g. the client has terminated).Server code:

#include <TCPServerSocket.hpp>
#include <string>


View 1 Replies (Posted: 03-27-2011, 07:56 PM)

Sponsored Links:

Related Forum Messages For Linux category:
Programming :: Unable To Catch The SIGTERM Signal?
But unable to catch the SIGTERM signal if I do shutdown, as man pages says shutdown genrates the SIGTERM and SIGKILL signals, but we cant handle the SIGKILL signal. My code is working fine if I genrate the SIGTERM signal by Kill command, and also for SIGINT signgal genrated from the CTRL+c key.

Here is my code:

/* Example of using sigaction() to setup a signal handler with 3 arguments
* including siginfo_t.
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>


Posted: 04-25-2011, 03:55 AM

View 5 Replies!   View Related
Software :: Process Cannot Catch The HUP Signal?
i write one program,which can dynamiclly be configure by user,using signal SIGHUP.if i start the program in console,it can works well.i.e,i send HUP signal to the process,it can be catched and load the configure file.but,if the program is started from init shell script,in this way,the ppid of the program is 1,the process can not catch the HUP signal but other signal ,such as USR1,can be catched.i don't know if i express clearly.i am not family with shell script.i don't know if it dues to starting from shell script

Posted: 02-03-2010, 01:21 AM

View 1 Replies!   View Related
Programming :: Sets Sigpipe's Default Action To Ignore And Opens A Socket?
I'm studying an OS programming book, in particular network sockets. I have two questions(2nd one is down at the bottom). There is something I don't quite understand. What if this piece of code, which sets sigpipe's default action to ignore and opens a socket:

if ((u_ignore_sigpipe() != 0) || ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1))
return -1;


Posted: 07-27-2011, 08:26 PM

View 3 Replies!   View Related
Programming :: Handle A Broken Pipe Exception (SIGPIPE) In FIFO Pipe?
I've written a simple server in linux used fork to create a FIFO pipe.The server create two FIFO pipe.One for server read data from client and write data to client.Then another pipe for client read data from server and write data to server.When the server read data from a client used server-pipe and then write data to client.But ,if the client no read open the pipe,the server side write will be crashed because of a broken-pipe SIGPIPE. How to check whether the read side is opened?Or,how to catch the SIGPIPE,and then my server will still execute on,not crashed!!

Posted: 03-02-2011, 11:24 PM

View 5 Replies!   View Related
Programming :: How Sed Can Catch Variable From Input?
right now i am writing bash script for simple everyday todo tasks.script consisit of two files, fisrt is just script (which can delete/append /clear) and second one is todolist.txt which stores my notes.I am litlebit confused about sed!!for example, If my todolist.txt have these lines:

- Writing my Homework
- take my girlfriend to launch
- Take a break

How can sed take my input $@ and delete all line with name "Homework"..i trayed with many sed combination like:

sed s/$@//g
sed 'd/$@/'
and many more combination with ""/'' or bracket but nothing helped

Posted: 02-02-2011, 06:04 AM

View 5 Replies!   View Related
Programming :: Catch Some Outputs In Two Different Log Files In Bash?
I want to catch some outputs in two different log files in bash, file simple.log and all.log So far, the script is started like this:


xterm -e "(./ | tee -a simple.log) >& all.log"

What I want is:

- In simple.log, I want all the stdout but WITHOUT errors.

- In all.log I want BOTH stdout and stderr.

So all is ok, and the output becomes:



starting copying files
mv: cannot move ... : permission denied
copying completed
simple log


starting copying files
copying completed

But, in the new xterm, I'm loosing stdout. There is no output.How can I have the files logged as they are but also have the stdout in the xterm.

Posted: 01-26-2009, 09:22 AM

View 6 Replies!   View Related
Programming :: Catch System-level Exceptions?
The following C++ program doesn't catch the exception:

#include <iostream>
using namespace std;


Posted: 01-24-2011, 06:49 PM

View 2 Replies!   View Related
Programming :: Python: Catch Stdout And Stderr From External Command?
After some Goggling I found out how to use os.popen("command") to run a command and catch the stdout. Problem now is that I want to catch stderr as well and they need to be separated. Is there anyone who knows how to do this? If it is too complex it will be enough to just ignore stdout and only catch stderr. The result should be that nothing goes to the screen and the script get the errors if there are any (maybe the error code as well, to determine how the execution went).

Posted: 02-27-2008, 03:57 PM

View 9 Replies!   View Related
Programming :: Catch User Input While The Bash Script Is Running?
How do you catch user input while the script is running? Or, how would you make two scripts run at the same time, but use input from one script to the other? The program I'm trying to make, echos text on the screen continuously, but while thats happening, I want the user to be able to input something, so the program can detect the input and display something else. So I thought maybe I could make two scripts run to do each task.

Posted: 10-30-2010, 12:27 PM

View 5 Replies!   View Related
Programming :: Bash Script: Catch File Not Found Error And Send To /dev/null
I have the following working script. It checks the directory for txt files, if files are there, it copies to another directory or gives error. I would like to exclude "file not found" errors and send them to /dev/null. All other errors should go to the email address as usual.


function err
if [[ $? -ne 0 ]]


Posted: 04-21-2010, 06:19 AM

View 7 Replies!   View Related
Programming :: Totem Python Plugin Programming: Any Signal For Video Mouse Click?
I want that I click with the mouse on the video, it paused.I notice that there is "BaconVideoWidget" which I guess is the video rendering widget but it don't have signal named "clicked":

vd = totem_object.get_video_widget()
vd.connect("clicked", vd.hide)


Posted: 02-09-2011, 09:33 AM

View 3 Replies!   View Related
Programming :: Signal Emitted With CTL+D In Bash?
I'm doing the shell history audit logging using syslog to gather the command history. I'm using this well publicized method using trap and logger:

declare -r REAL_LOGNAME=`/usr/bin/who am i | cut -d" " -f1`
function log2syslog {
declare command
command=`fc -ln -0`
logger -p local1.notice -t bash -i ": $REAL_LOGNAME as $LOGNAME :$command"
trap log2syslog DEBUG TERM

The problem is that the trap on DEBUG will catch the next to last command executed (by virtue of the "fc" command) which is not the current command executed. TERM will catch that "next to last" command on exit, thus completing the logging of each command executed during that session.

However, CTL+D doesn't seem to emit a SIGTERM signal. What signal is actually being emitted and can it be trapped? I guess another question would be whether there is a way to trap history after command line execution? Moving to Bash 4.1 isn't possible in our "supported" multi-platform environment

Posted: 10-22-2010

View 5 Replies!   View Related
Programming :: Signal Handling In Pthread?
I have created a pthread, and installed a signal handler inside that, same way as we do in main( ) function. The thread's signal handler is a separate function. Surprisingly, it is not working, that is the thread's signal handler is not able to catch signals. Here is the code:

Code: #include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <signal.h>
typedef struct data


Posted: 03-12-2011

View 1 Replies!   View Related
Programming :: Signal Error Shown - Bad Trap?
trap "echo Haha" SIGUSER1
echo "asit"
while [ $count -le 10 ]
echo "Loop #$count"
sleep 10
count=$[ $count + 1 ]
echo "This is the end"

Why this is showing following error?
trap: 3: SIGUSER1: bad trap

Posted: 06-16-2010, 01:23 PM

View 4 Replies!   View Related
Programming :: Use CTRL+D Signal In Bash Script?
I am writing a bash script where I need standard Input should be saved in a file and should be terminated by passing CTRL+D signal. Any clue how can I do that in bash script.

Enter one line at a time
Press CTRL+D to finish

Posted: 01-15-2010, 05:03 AM

View 1 Replies!   View Related
Programming :: Possible To Connect A Signal Handler To A Variable?
Is it possible to connect a signal handler to a variable?So when the variable changes the signal handler is called.I have a vector containing strings which i want to parse when there are one or more available strings in the vector

Posted: 11-01-2010

View 3 Replies!   View Related
Programming :: Stop User From Invoking Own Signal?
I have a signal handler in my tool, which is registered and used between some particular interval (i am using timer). Now this signal handler should NOT allow any other handler to be registered or invoked after this handler is once registered. Is there any way to accomplish this?


Posted: 04-27-2011

View 6 Replies!   View Related
Programming :: Temporarily Blocking Or Disconnecting A GTK+ Signal?
I'm just beginning to program with GTK+, and I'm facing this issue: I want to inhibit a signal emission inside one and only one function. I've down cut my code into the smallest example I can to show you what I want to do:The "Emitter" contains a "GtkSpinBox" and it relays the "value-changed" signal, it's header:

#ifndef EMITTER_H
#define EMITTER_H


Posted: 05-21-2010, 01:26 PM

View 1 Replies!   View Related
Programming :: Sequencing With Raising A Signal Method?
I was trying to program using fork(). The objective of this code is to

1. I am activating a process A - SubSuctionMotors.
2. Process A is going to stop with either of this condition
a) Switch is activated - swret=1
b) Time allowed has expired
3. Stop the process A.


1. We purposely force the switch to be inactive to test the child process (timer), whether after 2 seconds the motor stop. It turns out to be successful in first few attempts. After some while, the program hang, nothing is executed anymore and the program is not exit or terminated. What can cause the program to hang?

2. We tried to stop motor by switch activation (if the switch is to be successfully activated, the time it takes will always be shorter than the timer allowed time). However, the program did not seems like noticing the switch has been activated, and it just stop the motor according to timer. Why it behave this way?

Posted: 03-04-2010, 04:43 AM

View 4 Replies!   View Related
Programming :: Locking Mutex In A Signal Handler Function?
locking mutex (phtread_t type) in a signal handler function (installed by function signal()) for Linux. It seems that if the mutex has been previously locked by another thread outside the signal handler function and then the signal handler function tries to lock it, the whole process hangs.

Posted: 02-15-2010, 06:53 AM

View 5 Replies!   View Related
Programming :: Designing A Signal Handler With Sigwait In UNIX?
I'm new to Unix and every signal handler algorithm I've seen is more or less a copy of what I'm trying to do.[URL] designing a signal handler with sigwait in UNIX?

Posted: 01-20-2010, 05:48 AM

View 1 Replies!   View Related
Programming :: Why Does A Child Exit When The Parent Receives A Signal
I have a problem with the last point of some homework I have for an OS class. I need the program to print the pid upon execution, then for 10 seconds react to SIGUSR1, SIGUSR2 and SIGTERM. If either USR1 or USR2 is received, the 10 seconds are reset. Some of the functions I'm told to use are alarm(), pause() and signal(). The nicest way I found was to handle SIGUSR1, SIGUSR2 and SIGALRM in the parent process, with SIGALRM killing the child (with a SIGTERM). In the child a pause() (or for(; pause() would be enough for it to be alive until killed from the SIGALRM handler in the parent.

What I found is that I can't just do a wait() in the parent process, waiting for the child to be killed, since whenever the parent receives a SIGUSR1 or SIGUSR2, the right handler is called but the child exits nicely. I tried blocking/ignoring those signals in the child, since the default behaviour for SIGUSR1 and SIGUSR2 is to terminate the process, but the result is the same. The only way I could do it is using a waitpid() within a do { } while(!WIFSIGNALED(status)) since when the child gets killed with the parent's kill(), it's WIFSIGNALED, whereas when it exits after the parent handles a SIGUSR1/2, it's WIFEXITED.

P.S. What I'm doing to achieve the expected 10s window is calling alarm(10) in the parent process and again within the SIGUSR1/2 handlers. In the SIGALRM handler I kill the child and within the child I simply do a for(; pause()

Posted: 03-16-2011, 10:31 AM

View 4 Replies!   View Related
Programming :: Handle Keyboard Button Pressed Signal?
I'm learning Signals, and I have a question:

Is possible to make a handle when I press any of the keyboard buttons?

The SIGINT handles the Ctrl-C combination, but I want to handle if any keyboard button was pressed.

Posted: 07-04-2011, 10:45 AM

View 3 Replies!   View Related
Programming :: Missing Incoming Gpio Signal Pulses On Imx27
I am using an imx27 and have a timer set up for 100 ms and a loop to count the pulses while the timer has not expired. I get about 90 % reliable results but every once in a while i get one that is out to lunch. I am reading in a signal that is about 500khz and counting on an transition. I usually get around 85k count. But i will randomly get a 50k count.

Posted: 11-04-2010, 10:15 AM

View 3 Replies!   View Related
Copyright 2005-08, All rights reserved