Annotation of OpenXM/src/ox_math/test2.c, Revision 1.1
1.1 ! ohara 1: /* -*- mode: C -*- */
! 2: /* $OpenXM$ */
! 3:
! 4: #include <sys/types.h>
! 5: #include <sys/stat.h>
! 6: #include <fcntl.h>
! 7:
! 8: #include <stdio.h>
! 9: #include <stdlib.h>
! 10: #include <mathlink.h>
! 11: #include <unistd.h>
! 12: #include <signal.h>
! 13:
! 14: #define FNAME "/tmp/inttest00"
! 15:
! 16: static int signum = 0;
! 17:
! 18: static void handler()
! 19: {
! 20: print("handler(): signal received.");
! 21: }
! 22:
! 23: static int block0(int sig_no)
! 24: {
! 25: sigset_t mask;
! 26: sigemptyset(&mask);
! 27: sigaddset(&mask, sig_no);
! 28: sigprocmask(SIG_SETMASK, &mask, NULL);
! 29: }
! 30:
! 31: static int block(int sig_no)
! 32: {
! 33: int i;
! 34: sigset_t mask;
! 35: sigemptyset(&mask);
! 36: for(i=1;i<sig_no;i++) {
! 37: sigaddset(&mask, i);
! 38: }
! 39: sigprocmask(SIG_SETMASK, &mask, NULL);
! 40: }
! 41:
! 42: int print(char *s)
! 43: {
! 44: FILE *fp = fopen(FNAME, "w+");
! 45: fprintf(fp, "%s\n", s);
! 46: fclose(fp);
! 47: return 0;
! 48: }
! 49:
! 50: int INT_addto(int x, int y)
! 51: {
! 52: while (!MLAbort) {
! 53: sleep(3);
! 54: }
! 55: print("INT_addto(): MLAbort is set.");
! 56: return x+y;
! 57: }
! 58:
! 59: int INT_addtoo(int x, int y)
! 60: {
! 61: return x+y;
! 62: }
! 63:
! 64: int INT_signal(int n)
! 65: {
! 66: signal(n, handler);
! 67: signum=n;
! 68: return n;
! 69: }
! 70:
! 71: int INT_block(int n)
! 72: {
! 73: block(n);
! 74: return n;
! 75: }
! 76:
! 77: int main(int argc, char *argv[])
! 78: {
! 79: ox_stderr_init(NULL);
! 80: MLMain(argc, argv);
! 81: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>