signals

Help with sigprocmask()

I haven't completely understood how to use sigprocmask(). Particularly how the set and oldset in its syntax work and how to use them. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); Please explain with an example used to block, say SIGUSR1 for a few seconds and then unblock and handle it. ...

Print Odd-Even numbers using signals

The problem is to print natural nos. 1,2,...n such that the parent process prints all odd numbers and child all even numbers using POSIX signals. Output should be: Parent : 1 Child : 2 Parent : 3 and so on...any suggestions? ...

Handle signals in the Java Virtual Machine

Is it possible to handle POSIX signals within the Java Virtual Machine? At least SIGINT and SIGKILL should be quite platform independent. ...

True timeout on LWP::UserAgent request method

I am trying to implement a request to an unreliable server. The request is a nice to have, but not 100% required for my perl script to successfully complete. The problem is that the server will occasionally deadlock (we're trying to figure out why) and the request will never succeed. Since the server thinks it is live, it keeps the so...

Converting floating point exceptions into C++ exceptions

Is it possible to convert floating point exceptions (signals) into C++ exceptions on x86 Linux? This is for debugging purposes, so nonportability and imperfection is okay (e.g., if it isn't 100% guaranteed that all destructors are called). ...

Portable way to catch signals and report problem to the user.

If by some miracle a segfault occurs in our program, I want to catch the SIGSEGV and let the user (possibly a GUI client) know with a single return code that a serious problem has occurred. At the same time I would like to display information on the command line to show which signal was caught. Today our signal handler looks as follows...

How to prevent SIGPIPEs (or handle them properly).

I have a small server program that accepts connections on a TCP or local UNIX socket, reads a simple command and, depending on the command, sends a reply. The problem is that the client may have no interest in the answer sometimes and exits early, so writing to that socket will cause a SIGPIPE and make my server crash. What's the best pr...

Python signal woes: SIGQUIT handler delays execution if SIGQUIT recieved during execution of another signal handler?

The following program is very simple: it outputs a single dot each half a second. If it recieves a SIGQUIT, it proceeds to output ten Qs. If it recieves a SIGTSTP (Ctrl-Z), it outputs ten Zs. If it recieves a SIGTSTP while printing Qs, it will print ten Zs after it's done with the ten Qs. This is a good thing. However, if it recieves a...

What are the Python equivalents of the sighold and sigrelse functions found in C?

It appears the Python signal module doesn't have anything similar to the sighold and sigrelse functions found in C, using signal.h. Are there Python equivalents of any sort? Many thanks! ...

Is there a way to have managed processes in Perl (i.e. a threads replacement that actually works)?

I have a multithreded application in perl for which I have to rely on several non-thread safe modules, so I have been using fork()ed processes with kill() signals as a message passing interface. The problem is that the signal handlers are a bit erratic (to say the least) and often end up with processes that get killed in inapropriate st...

How to handle a ctrl-break signal in a command line interface

Before I begin, I want to clarify that this is not a command-line tool, but an application that accepts commands through it's own command-line interface. Edit: I must apologize about my explanation from before, apparently I didn't do a very good job at explaining it. One more time... I am building a command-line interface application t...

Processing Linux SIGnals using Gambas

I would like to send a (as yet undetermined) SIGnal from a bash script to a Gambas program when a specific file has been changed. How can I get my Gambas program to process this SIGnal? ...

What is the difference between sigaction and signal?

I was about to add an extra signal handler to an app we have here and I noticed that the author had used sigaction to set up the other signal handlers. I was going to use signal. To follow convention I should use sigaction but if I was writing from scratch, which should I choose? ...

How can I catch and handle a signal in Perl?

Is there any way to trap an error and exit gracefully from Perl? I am working on a script which might fail due to a SIG event from the OS or other applications running on my server. I wish to trap this event, display the error and exit after closing all files and other attributes I have open during the execution of the script. ...

How can I prevent Windows from catching my Perl exceptions?

I have this Perl software that is supposed to run 24/7. It keeps open a connection to an IMAP server, checks for new mail and then classifies new messages. Now I have a user that is hibernating his XP laptop every once in a while. When this happens, the connection to the server fails and an exception is triggered. The calling code usual...

Find PID of a Process by Name without Using popen() or system()

I've a process name and I've to send a kill() signal to that process but I need its PID to call kill(). I would only like to use: popen("pidof process_name"); as the last thing. Is there any other way to find out the process' PID? One way I could think of is to send a socket request to that process and ask to its PID. The other way i...

How should I close a socket in a signal handler?

I'm writing a very simple server that loops forever until Ctrl-C is pressed. I'd like to have the signal handler for ctrl-c close the open sockets and shut down the server, but I don't know what the scope is for a signal handler, and I don't like the idea of declaring the socket(s) I would need to close to be global. Can someone offer s...

What is a signal in Unix?

This comment confuses me: "kill -l generally lists all signals". I thought that a signal means a quantized amount of energy. [Added] Please, clarify the (computational) signal in Unix and the physical signal. Are they totally different concepts? [Added] Are there major differences between paradigms? Is the meaning the same in languages...

Using SIGINT

According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i cause a SIGINT in c++? i seen an example using kill(pid, SIGINT); but i rather cause it another way. Also i am using windows. ...

A more natural boost::bind alternative?

Don't get me wrong: Boost's bind() is great. But I do hate to write&read code with it, and I've given up hope my coworkers will ever grok/use it. I end up with code like this: btn.clicked.connect(bind(&BetBar::placeBet, this, bet_id)); animator.eachFrame.connect(bind(&Widget::move, buttons[bet_id])); Which, while logical, is very fa...