How to let the process exit if the signal its waiting for doesn't arrive



Hi!

I have a question about how to create a process in such a way that it
would terminate itself if its wated for input for too long.

Here is the story. I have 2 different files, say R.c and S.c, which
have a named pipe between them and send each other signals. R process
starts first, it opens a named pipe and waits for S to connect. S
connects to the pipe, writes something to it and sends the signal to R
indicating that R can read. When R receives a signal from S, it reads
the data, sends the signal back to S that the data was read, and
suspends waiting for another signal from S to read again, and so on.

My question is when R just starts and waits for S to connect, in case S
doesn't connect, so that R would wait indefinitely, is there a way to
set a clock or something in R to terminate after some time, without
affecting the rest of the execution in case S does connect.

Sorry if my explanation is a little all over the place...
I'd really appreciate any help or any ideas.

Thanks a lot
norm4h8

.



Relevant Pages

  • Re: How to let the process exit if the signal its waiting for doesnt arrive
    ... would terminate itself if its wated for input for too long. ... have a named pipe between them and send each other signals. ... it opens a named pipe and waits for S to connect. ... set a clock or something in R to terminate after some time, ...
    (comp.lang.c)
  • Re: Process with many NPTL threads terminates slowly on core dump signal
    ... clear false pending signal indication in core dump ... > to terminate if it receives a signal that may cause a core dump. ... > program is designed to consume infinite CPU time). ... > * The slow process termination time only occurs for those signals that ...
    (Linux-Kernel)
  • Re: How to let the process exit if the signal its waiting for doesnt arrive
    ... would terminate itself if its wated for input for too long. ... have a named pipe between them and send each other signals. ... it opens a named pipe and waits for S to connect. ... set a clock or something in R to terminate after some time, ...
    (comp.lang.c)
  • Re: Signals, threads and the use of SIGUSR1
    ... No, I think that SIGINT, SIGHUP and SIGTERM are the signals to be covered in ... >> that's OK to just terminate your process as usual, ... if you don't send explicitely SIGUSR1 to that thread upon ...
    (comp.unix.programmer)
  • Re: NMEA ref.clock better than my ISPs timeserver?
    ... David J Taylor wrote: ... signals. ... On very long runs, you would not only need to terminate the cable correctly, you would need to drive it correctly as well, requiring powered line drivers and receivers at either end. ... To play safe with the ttl level pps I've setup to use a simple ...
    (comp.protocols.time.ntp)