linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Any known problems with usleep() in 2.6.7?
@ 2004-07-13 19:34 Matthias Grimm
  2004-07-16 18:56 ` Matthias Grimm
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Grimm @ 2004-07-13 19:34 UTC (permalink / raw)
  To: linuxppc-dev


Hi,
Recently I have had a strange phenomenon with kernel 2.6.7: sometimes usleep()
doesn't return. it  hangs. I haven't discovered yet under which circumstances
usleep() doesn't work. With kernel 2.4 I haven't seen this behaviour.

Are there any known problems with usleep() in kernel 2.6.7?
Is there a better method to wait a while?

I attached the code fragment with the problematic usleep() call. that. Maybe
there is something wrong I haven't seen yet. I would appreciate every hint.
I know that I should check the return value of fork() for error but this has
nothing to do with the usleep() problem, because the child has been created.

 Best Regards
    Matthias Grimm

--------------
	pid = fork();
	if (pid == 0) {
		for (i=0; i < maxfiles; i++)
			close(i);      /* close all possible file handles */

		open("/dev/null", O_RDONLY);  /* STDIN */
		open("/dev/null", O_WRONLY);  /* STDOUT */
		open("/dev/null", O_WRONLY);  /* STDERR */

		execv(argv[0], argv);
		exit(99);
	}
	rc = E_CLDKILL;
	for (i=base->timeforcmd * 10; i > 0; i--) {
		usleep(100000);  /* sleep 100ms */
		if (waitpid (pid, &status, WNOHANG)) {
			if (WIFEXITED(status)) {
				if ((base->rc = WEXITSTATUS(status)))
					rc = E_CLDEXIT;
				else
					rc = 0;
			} else if (WIFSIGNALED(status))
				rc = E_CLDSIG;
			break;
		}
	}
	if (i == 0)
		kill (pid, SIGKILL);
---------

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
** This list is shutting down 7/24/2004.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Any known problems with usleep() in 2.6.7?
  2004-07-13 19:34 Any known problems with usleep() in 2.6.7? Matthias Grimm
@ 2004-07-16 18:56 ` Matthias Grimm
  0 siblings, 0 replies; 2+ messages in thread
From: Matthias Grimm @ 2004-07-16 18:56 UTC (permalink / raw)
  To: linuxppc-dev


Hi,
The function usleep() is ok in 2.6.7. I didn't saw that my process had been
stopped and therefore didn't react anymore. After some time of searching I
found the process that stopped my process and why. After that it wasn't
difficult to find the bug in my program.

 Thanks for assistance
    Matthias

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-16 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-13 19:34 Any known problems with usleep() in 2.6.7? Matthias Grimm
2004-07-16 18:56 ` Matthias Grimm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).