nanosleep returns prematurely, with return value 0


 
Thread Tools Search this Thread
Top Forums Programming nanosleep returns prematurely, with return value 0
# 1  
Old 12-21-2008
nanosleep returns prematurely, with return value 0

Hi,

I have encountered the following problem on Solaris 10:

I have a thread that is asleep on nanosleep (set to 24 hours).

Something that happens on another thread, causes the nanosleep to exit, even though the time has not elapsed.
The returned value is 0 (so it doesn't look like it wakes due to a signal, at least according to the man pages).

The action on the other thread that triggers the nanosleep wake seems to be a TCP connection being established.
Also, it's possible that it happens only when 2 different TCP connections are being established concurrently in 2 other threads.

Obviously some actions are taken by the other threads when a connection is made, including various socket and network calls, like accept(), select(), inet_addr(), inet_ntoa(), gethostbyname(), etc. But I don't see how any of it can be related to the nanosleep() waking.

My questions are:

* What could make nanosleep return ahead of time and return 0?

* Can a memory override possibly make this happen?

Any insight, direction or idea would be greatly appriciated!

Thanks.
# 2  
Old 12-21-2008
Source code for nanosleep() can be viewed in the OpenSolaris source code repository.
The relevant file is .../src/uts/common/os/timers.c.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Nanosleep in signal call

Hi @ll :) I have a problem with my code but first a short description: 1. I have one signal call SIGUSR1 2. In the signal I try to use nanosleep and now: When I put kill -SIGUSR1 pid --> sometimes works fine, sometimes returns me an error with ,,Interrupt system call", sometimes I got... (5 Replies)
Discussion started by: mattdj
5 Replies

2. Shell Programming and Scripting

Expect script cronjob running but dying prematurely

I have an Ubuntu machine that I'd like to update automatically. I've written an expect script to run the aptitude package manager and update my packages. Essentially it does: aptitude update && aptitude upgrade while answering "yes" at the appropriate time. It works quite nicely when run... (4 Replies)
Discussion started by: CluelessPerson
4 Replies

3. Shell Programming and Scripting

sqlplus returns leading carriage return into a variable

I am trying to generate some scripts to help manage an Oracle database. When I check the value returned from Oracle it has a leading carriage return in the variable. Is there a way to prevent this? Is there a way to easily strip out the carriage return. See code and output below. ... (7 Replies)
Discussion started by: Panzer993
7 Replies

4. Programming

nanosleep

Application runs on both solaris 6 and 10. solaris 6 having only posix4.so library, solaris 10 having libposix4.so and librt.so Can we link application to lposix4 instead of lrt for nanosleep, sothat application will run in both machines? (2 Replies)
Discussion started by: satish@123
2 Replies

5. Shell Programming and Scripting

Background program exits prematurely?

Hello! I am currently attempting to build a very, very, basic program that attempts to act like a calendar for a "server." Using this program I need to have the client program connect to the server program, have the client wait for the server to respond through a socket, then exit and the server... (2 Replies)
Discussion started by: Entelexia
2 Replies

6. Programming

Where is nanosleep?

I use nanosleep under solaris10,like follows: #include <pthread.h> #include <time.h> #include <sys/time.h> struct to_info{ void (*to_fn)(void *); void *to_arg; struct timespec to_wait; }; void *timeout_helper(void *arg){ struct to_info *tip; nanosleep(&tip->to_wait,NULL);... (1 Reply)
Discussion started by: konvalo
1 Replies

7. UNIX for Advanced & Expert Users

script dies prematurely and unpredictably

Hi, I have over 5 gb of data in a files structure in which month folders are in year folders, day folders are in month folders, and individual climate stations are in each day. I am trying to extract precipitation measured at 5 minute intervals for a duration of 15 years, but the script never... (2 Replies)
Discussion started by: mlw63@me.com
2 Replies

8. Infrastructure Monitoring

Nagios escalating prematurely

We are currently using Nagios 1.3 .The issue we facing is , when a alert is in Warning state and then from Warning it moves to Critical state ,the alert is escalated directly to L2,L3 L4 escalations,here nagios assumes that the time period ,the alert was in warning state as unacknowledged time... (0 Replies)
Discussion started by: apatil
0 Replies

9. Programming

nanosleep

Hello, Can anyone, please, guide me on the use of nanosleep. I'm learning threads. I want to introduce a delay (not nested for loops, something more customizable). Nanosleep looked useful (or any other form of customizable and easy-to-use delay). Sleep is too long. :) (2 Replies)
Discussion started by: ameya
2 Replies

10. Shell Programming and Scripting

Why does rexec cause while loop to end prematurely?

I have the following korn shell script which reads the contents of an ascii file and performs an rexec command based on the line that was just read from the ascii file. The ascii file contains 6 lines, thus, the while loop should execute 6 times. The problem is that the rexec command within the... (2 Replies)
Discussion started by: sadove
2 Replies
Login or Register to Ask a Question