[git commit future] waitpid.c: provide __waitpid_nocancel, use cancel.h
Peter S. Mazinger
ps.m at gmx.net
Wed Apr 20 10:50:38 UTC 2011
commit: http://git.uclibc.org/uClibc/commit/?id=686e4558ecc74e0414415ce470e86ae57f0aaafa
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future
Use __wait4_nocancel since wait4 is not available all the time.
Add a comment about not using waitpid syscall.
Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
include/sys/wait.h | 3 +++
libc/sysdeps/linux/common/waitpid.c | 32 ++++++++------------------------
2 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/include/sys/wait.h b/include/sys/wait.h
index b09c28d..2b68847 100644
--- a/include/sys/wait.h
+++ b/include/sys/wait.h
@@ -137,7 +137,10 @@ extern __pid_t wait (__WAIT_STATUS __stat_loc);
This function is a cancellation point and therefore not marked with
__THROW. */
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
+#ifdef _LIBC
+extern __typeof(waitpid) __waitpid_nocancel attribute_hidden;
libc_hidden_proto(waitpid)
+#endif
#if defined __USE_SVID || defined __USE_XOPEN
# define __need_siginfo_t
diff --git a/libc/sysdeps/linux/common/waitpid.c b/libc/sysdeps/linux/common/waitpid.c
index d043719..b5a9b18 100644
--- a/libc/sysdeps/linux/common/waitpid.c
+++ b/libc/sysdeps/linux/common/waitpid.c
@@ -6,32 +6,16 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <stdlib.h>
-#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/resource.h>
+#include <cancel.h>
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include "sysdep-cancel.h"
-#else
-#define SINGLE_THREAD_P 1
-#endif
-
-libc_hidden_proto(wait4)
-
-extern __typeof(waitpid) __libc_waitpid;
-__pid_t __libc_waitpid(__pid_t pid, int *wait_stat, int options)
+pid_t __NC(waitpid)(pid_t pid, int *wait_stat, int options)
{
- if (SINGLE_THREAD_P)
- return wait4(pid, wait_stat, options, NULL);
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
- int oldtype = LIBC_CANCEL_ASYNC ();
- int result = wait4(pid, wait_stat, options, NULL);
- LIBC_CANCEL_RESET (oldtype);
- return result;
+#if 1 /* kernel says to avoid waitpid syscall */
+ return __wait4_nocancel(pid, wait_stat, options, NULL);
+#else
+ return INLINE_SYSCALL(waitpid, 3, pid, wait_stat, options);
#endif
}
-libc_hidden_proto(waitpid)
-weak_alias(__libc_waitpid,waitpid)
-libc_hidden_weak(waitpid)
+CANCELLABLE_SYSCALL(pid_t, waitpid, (pid_t pid, int *wait_stat, int options), (pid, wait_stat, options))
+lt_libc_hidden(waitpid)
--
1.7.3.4
More information about the uClibc-cvs
mailing list