[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Provide raise



raise is implemented by LinuxThreads in terms of pthread_kill, like
SUSv3 specifies.
This patch makes nptl do the same thing.


--- nptl/Versions~	2002-11-01 03:20:32.000000000 +0100
+++ nptl/Versions	2002-11-01 16:44:16.000000000 +0100
@@ -93,6 +93,9 @@ libpthread {
     # Special fork handling.
     fork; __fork; vfork;
 
+    # Thread specific signal functions.
+    raise;
+
     # Cancellation points.
     close; __close; fcntl; __fcntl; read; __read; write; __write; accept;
     connect; recv; recvfrom; recvmsg; send; __send; sendmsg; sendto; fsync;
--- nptl/Makefile~	2002-11-01 03:20:32.000000000 +0100
+++ nptl/Makefile	2002-11-01 16:40:53.000000000 +0100
@@ -102,7 +102,7 @@ libpthread-routines = init events \
 		      pt-wait pt-waitpid pt-readv pt-writev pt-creat \
 		      pt-msgrcv pt-msgsnd pt-poll pt-select pt-sigpause \
 		      pt-sigsuspend pt-sigwait pt-sigwaitinfo pt-waitid \
-		      pt-pselect pt-fork \
+		      pt-pselect pt-fork pt-raise \
 		      flockfile ftrylockfile funlockfile \
 		      sigaction

--- /dev/null	1970-01-01 01:00:00.000000000 +0100
+++ nptl/pt-raise.c	2002-11-01 16:40:38.000000000 +0100
@@ -0,0 +1,31 @@
+/* Linuxthreads - a simple clone()-based implementation of Posix        */
+/* threads for Linux.                                                   */
+/* Copyright (C) 1996 Xavier Leroy (Xavier Leroy inria fr)              */
+/*                                                                      */
+/* This program is free software; you can redistribute it and/or        */
+/* modify it under the terms of the GNU Library General Public License  */
+/* as published by the Free Software Foundation; either version 2       */
+/* of the License, or (at your option) any later version.               */
+/*                                                                      */
+/* This program is distributed in the hope that it will be useful,      */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of       */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */
+/* GNU Library General Public License for more details.                 */
+
+#include <errno.h>
+#include <sysdep.h>
+#include "pthreadP.h"
+
+/* Redefine raise() to send signal to calling thread only,
+   as per POSIX 1003.1c */
+int raise (int sig)
+{
+	int retcode = pthread_kill((pthread_t) THREAD_SELF, sig);
+	if (retcode == 0)
+		return 0;
+	else
+	{
+		errno = retcode;
+		return -1;
+	}
+}

Attachment: pgp00025.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]