/* $Id: tdaq.c,v 1.3 2003/03/29 06:18:42 wafer Exp $ */ /* These routines know how to run turbo-daq */ #include #include #include #include #include #include #include #include #include "inst.h" static char _tdaq_running = 0; static char _tdaq_exited = 0; static pthread_mutex_t _mut; static pthread_t _thr; void *tdaq_start (void *); int tdaq_init () { int err; /* get a mutex */ if (err = pthread_mutex_init(&_mut, NULL)) { fprintf(stderr, "%s", strerror(err)); exit(1); } /* start up a thread that watches over turbo-daq */ if (err = pthread_create(&_thr, NULL, tdaq_start, NULL)) { fprintf(stderr, "%s", strerror(err)); exit(1); } return 0; } void *tdaq_start (void *p) { pid_t pid = fork(); int err; int status; if (pid == -1) { fprintf(stderr, "%s", strerror(err)); exit(1); } else if (pid == 0) { /* execl("/cygdrive/c/johannes-tdaq/TurboDAQ_3.6/TurboDAQ.exe", */ execl("/bin/ls", "ls", ".", NULL); fprintf(stderr, "execl: %s", strerror(errno)); } else { if (waitpid(pid, &status, 0) == -1) { fprintf(stderr, "%s", strerror(errno)); exit(1); } printf("Done executing tdaq\n"); } return NULL; }