The Pth 1.4.1 manual states that system() is supported in the 
"Soft System Call Mapping", but in fact it is omitted (as an
oversight, I think).

Build Pth with --enable-syscall-soft, then compile this test
program with -E to show the preprocessed code:

#include "pthread.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main() {
        const char* msg = "... calling write() explicitly\n";
        pthread_t dummy = pthread_self();
        int rc = system("/bin/echo jls");
        fprintf(stderr,"... after system call, rc %d\n", rc);
        write(2, msg, strlen(msg));
}

You'll see that write has become __pthread_write, but system
is still system.

The fixes are to pthread.h.in:

--- pthread.h.in..orig  Sun Jan 27 06:03:41 2002
+++ pthread.h.in        Tue Oct 15 12:15:21 2002
@@ -503,6 +504,7 @@
 #if _POSIX_THREAD_SYSCALL_SOFT && !defined(_PTHREAD_PRIVATE)
 #define fork       __pthread_fork
 #define sleep      __pthread_sleep
+#define system     __pthread_system
 #define sigwait    __pthread_sigwait
 #define waitpid    __pthread_waitpid
 #define connect    __pthread_connect
 
and pthread.c:

--- pthread.c..orig     Thu Sep 12 15:13:15 2002
+++ pthread.c   Tue Oct 15 12:17:57 2002
@@ -1057,6 +1057,12 @@
     return pth_sleep(sec);
 }
 
+int __pthread_system(const char *cmd)
+{
+    pthread_initialize();
+    return pth_system(cmd);
+}
+
 int __pthread_sigwait(const sigset_t *set, int *sig)
 {
     pthread_initialize();


Jonathan Schilling              SCO/Caldera             [EMAIL PROTECTED]
______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
User Support Mailing List                            [EMAIL PROTECTED]
Automated List Manager (Majordomo)           [EMAIL PROTECTED]

Reply via email to