[lkml]   [2003]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[BUG - HRT patch] nanosleep returns 0 on failure
George -
In the latest 2.5.54-bk1 high-res-timers patches, it appears that
nanosleep() is returning 0 (success) and not setting errno when an rqtp
argument is sent that specifies a nsec value < 0 or >= 1000 million. In
this instance, the POSIX System Interfaces doc states that errno is supposed
to be set to EINVAL, and nanosleep should return -1.

In the 2.5.50 high-res-timers patches, behavior was as expected (i.e.,
returned -1 and set errno=EINVAL). Unfortunately, I haven't looked at any
patches since then to know exactly which patch stopped behaving as expected.
A plain 2.5.54-bk1 kernel also behaves as expected (returns -1, sets

The tests I am using to reproduce this issue are part of the POSIX Test
Suite at under
posixtestsuite/conformance/interfaces/nanosleep. 5-1.c (sending -1 nsec),
6-1.c (sending multiple nsec values < 0 and >= 1,000 million), and 10000-1.c
(sending other nsec values < 0 and >= 1,000 million) are failing. I've
included 5-1.c below.

Additional information is below:
kernel used = 2.5.54-bk1
HRT patches applied =

- Julie Fleischer

test 5-1.c below
(Output was: nanosleep() did not return -1 on failure)

* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.

* Test that nanosleep() returns -1 on failure.
* Simulate failure condition by sending -1 as the nsec to sleep for.
#include <stdio.h>
#include <time.h>

#define PTS_PASS 0
#define PTS_FAIL 1

int main(int argc, char *argv[])
struct timespec tssleepfor, tsstorage;
int sleepnsec = -1;

if (nanosleep(&tssleepfor, &tsstorage) == -1) {
printf("Test PASSED\n");
return PTS_PASS;
} else {
printf("nanosleep() did not return -1 on failure\n");
return PTS_FAIL;

printf("This code should not be executed.\n");

**These views are not necessarily those of my employer.**
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:32    [W:0.031 / U:4.804 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site