[BACK]Return to test-nanosleep.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

File: [cvsweb.bsd.lv] / mandoc / test-nanosleep.c (download)

Revision 1.1, Wed Jul 20 14:03:06 2016 UTC (7 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_6, VERSION_1_14_5, VERSION_1_14_4, VERSION_1_14_3, VERSION_1_14_2, VERSION_1_14_1, VERSION_1_13, HEAD

Autodetect if -lrt is needed for nanosleep(3).
Helpful for Solaris 9 and 10.
Reminded by Thomas Klausner.

#include <stdio.h>
#include <time.h>

int
main(void)
{
	struct timespec	 timeout;

	timeout.tv_sec = 0;
	timeout.tv_nsec = 100000000;	/* 0.1 seconds */
	
	if (nanosleep(&timeout, NULL)) {
		perror("nanosleep");
		return 1;
	}
	return 0;
}