Thread Tools Search this Thread
Top Forums Programming SIGALRM Help
# 1  
Old 06-16-2002
Question SIGALRM Help

A Unix system command needs to be executed from a C/C++ program. How do I use the SIGALRM in this case to stop processing the command after a few sec.
For eg, if the command is to connect to a database and the server is down, I would want to try for say 15 sec then give a timeout error.
How do I code this ?
# 2  
Old 06-16-2002
Most commands already have a timeout built-in to them. I would just go with that.

But to do what you asked, I would:

1 fork()

2a the child process would exec() the command in question

2b the parent process would sleep(15) ; then kill its child
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Programming

Runaway SIGALRM signal handler

I have written a program to demonstrate a problem I have encountered when using BSD style asynchronous input using the O_ASYNC flag in conjunction with a real time interval timer sending regular SIGALRM signals to the program. The SIGIO handler obeys all safe practices, using only an atomic update... (8 Replies)
Discussion started by: stewartw
8 Replies
Login or Register to Ask a Question