4 * $DragonFly: src/test/sysmsg/sysmsg1.c,v 1.1 2003/08/12 02:29:41 dillon Exp $
9 #include <sys/msgport.h>
11 #include <sys/syscall.h>
12 #include <sys/sysproto.h>
21 main(int ac, char **av)
23 struct write_args writemsg;
24 struct nanosleep_args sleepmsg;
29 printf("synchronous sendsys() test: write 'hello!' and 1.5 second nanosleep\n");
30 bzero(&writemsg, sizeof(writemsg));
31 writemsg.usrmsg.umsg.ms_cmd = SYS_write;
32 writemsg.usrmsg.umsg.ms_flags = 0;
34 writemsg.buf = "hello!\n";
36 error = sendsys(NULL, &writemsg.usrmsg, sizeof(writemsg));
37 printf("error code %d\n", error);
41 bzero(&sleepmsg, sizeof(sleepmsg));
42 sleepmsg.usrmsg.umsg.ms_cmd = SYS_nanosleep;
43 sleepmsg.usrmsg.umsg.ms_flags = 0; /* NOTE: not async */
47 ts1.tv_nsec = 500 * 1000000;
48 error = sendsys(NULL, &sleepmsg.usrmsg, sizeof(sleepmsg));
49 printf("error code %d\n", error);
50 if (error == EASYNC) {
51 struct nanosleep_args *rmsg;
52 printf("async return, waiting...");
55 rmsg = (void *)sendsys(NULL, NULL, -1);
56 printf(" rmsg %p\n", rmsg);
57 if (rmsg == &sleepmsg)
61 printf("async return error %d\n", sleepmsg.usrmsg.umsg.ms_error);
63 printf("error %d\n", error);