Sponsored Content
Full Discussion: Timed wait?
Top Forums Programming Timed wait? Post 302124277 by blowtorch on Friday 29th of June 2007 09:33:50 AM
Old 06-29-2007
You could combine both of vino's suggestions and have a loop where you wait with WNOHANG and then sleep for a second. Have a counter to achieve your timeout condition.

This might be wasteful of CPU though.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Connection Timed out

I connect to a Sun Box through telnet but it timed out in couple of minutes. Advance thanks for any idea...help... (2 Replies)
Discussion started by: s_aamir
2 Replies

2. UNIX for Dummies Questions & Answers

timed commands

Hello, How can I set up events to be executed at a certain time? And do I need some kind of privilege such as being in cron group? (2 Replies)
Discussion started by: rayne
2 Replies

3. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies

4. HP-UX

connection timed out

I am trying to connect with my hp machine using "dialup networking." It times out after 30 seconds. Is there a way to adjust this time. Would it have anything to do with rexec? thanks (0 Replies)
Discussion started by: paschal
0 Replies

5. UNIX for Dummies Questions & Answers

Timed read command

Hi guys, I love unix....but i also hate it :) I want to write a script that will pause in the middle ask for user input, but if no input is given i want the script to continue anyway. Say ask a question and give 1 min to answer and if no answer at all the script continues. (2 Replies)
Discussion started by: Noob e
2 Replies

6. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

7. Solaris

I/O timed out

I have Ultra 45 Sun solaris box with Solaris 10 installed. My problem is when i boot the unix box, i got the message: What does this message meant? then it does not continue to boot successfully. Please help. Thanks in advance. (5 Replies)
Discussion started by: etcpasswd
5 Replies

8. Shell Programming and Scripting

Timed Scripts

Hi all I need a little bit of help, i am looking for a script that can have different events in it and then if it is a certain day email me about it some sort of email reminder system any ideas thanks (4 Replies)
Discussion started by: ab52
4 Replies

9. Shell Programming and Scripting

timed kill within script?

I want to warn everyone, I am not a programmer lol. I'm an IT wanting to get a little insight of programming, and I like to play around so I can learn. Ok, so I'm going to school for IT Security and Forensics. I had a project to write a hack, and I chose to write a shell script to run dd to write... (8 Replies)
Discussion started by: joshbgosh10592
8 Replies

10. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies
pthread_cond_wait(3T)													     pthread_cond_wait(3T)

NAME
pthread_cond_wait(), pthread_cond_timedwait() - wait or timed wait on a condition variable SYNOPSIS
Parameters cond Pointer to the condition variable to be waited on. mutex Pointer to the mutex associated with the condition variable cond. abstime Absolute time at which the wait expires, even if the condition has not been signaled or broadcast. DESCRIPTION
The function is used to wait for the occurrence of a condition associated with the condition variable cond. The function is used to wait a limited amount of time for the occurrence of a condition associated with the condition variable cond. The abstime parameter specifies the time at which this function should time out. If the absolute time specified by abstime passes and the indicated condition has not been signaled, the function returns an error to the caller. Note: abstime is the time at which the wait expires, not the length of time the thread will wait. The condition variabled denoted by cond must have been dynamically initialized by a call to or statically initialized with the macro Both functions should be called with mutex locked by the calling thread. If mutex is not locked by the calling thread, undefined behavior will result. These functions atomically release mutex and cause the calling thread to block on the condition variable cond. If another thread is able to acquire the mutex after the about-to-block thread has released it but before it has actually blocked, a subsequent call to or by the other thread will behave as if it were issued after the about-to-block thread has blocked. When the condition is signaled or the timed wait expires, the caller is unblocked and will reacquire mutex before returning. Whether these functions succeed or fail, mutex will always be reacquired before returning to the caller. Using different mutexes for concurrent calls to these functions on the same condition variable results in undefined behavior. When using condition variables, there is a predicate associated with the condition wait. If this predicate is false, the thread should perform a condition wait. Spurious wakeups may occur when waiting on a condition variable. A spurious wakeup occurs when a thread returns from a condition wait when it should really continue waiting. A normal signal being delivered to a thread may cause a spurious wakeup dur- ing a condition wait. Since the return values from and do not imply anything about the value of the predicate, the predicate should be re- evaluated. A condition wait is a When the calling thread has deferred cancellation enabled, cancellation requested will be acted upon. If a cancella- tion request is acted upon while a thread is blocked in one of these functions, mutex is reacquired before calling the cancellation cleanup handlers. The cancellation cleanup handlers should release mutex so that application deadlock does not occur. If the condition signal and the cancellation request both occur, the canceled thread will not consume the condition signal (i.e., a different thread will be unblocked due to the condition signal). If a signal is delivered to a thread waiting for a condition variable, upon return from the signal handler, the thread may return zero due to a spurious wakeup or continue waiting for the condition. RETURN VALUE
and return the following values: Successful completion. Failure. An error number is returned to indicate the error. (The variable is not set.) ERRORS
The following error value is returned by if the corresponding condition is detected. abstime has passed and a condition signal has not been received. One of the following error values is returned by and if the corresponding condition is detected. A cond, mutex, or abstime parameter points to an illegal address. The value specified by cond, mutex, or abstime is invalid. mutex is not owned by the calling thread. This error is not returned for a or mutex on HP-UX. Different mutexes are being used for cond. This error is not detected on HP-UX. WARNINGS
It is important to note that when or return without error, the associated predicate may still be false. When returns with the timeout error, the associated predicate may be true. It is recommended that a condition wait be enclosed in the equivalent of a "while loop," which checks the predicate. Undefined behavior results if these functions are called with a mutex. EXAMPLES
is recommended to be used in a loop testing the predicate associated with it. This will take care of any spurious wakeups that may occur. is also recommended to be used in a loop. This function can return success even if the predicate is not true. It should be called in a loop while checking the predicate. If the function times out, the predicate may still have become true. The predicate should be checked before processing the timeout case. The example given below does not do any other error checking. AUTHOR
and were derived from the IEEE POSIX P1003.1c standard. SEE ALSO
pthread_cond_init(3T), pthread_cond_signal(3T). STANDARDS CONFORMANCE
Pthread Library pthread_cond_wait(3T)
All times are GMT -4. The time now is 04:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy