4 * $DragonFly: src/test/sysmsg/sysmsg2.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("test synchronous syscall msg write 'hello!'\n");
30 printf("test ASynchronous syscall msg nanosleep for 1.5 seconds\n");
31 printf("WARNING! super-user only, do not ^C the test program!\n");
33 bzero(&writemsg, sizeof(writemsg));
34 writemsg.usrmsg.umsg.ms_cmd = SYS_write;
35 writemsg.usrmsg.umsg.ms_flags = 0;
37 writemsg.buf = "hello!\n";
39 error = sendsys(NULL, &writemsg.usrmsg, sizeof(writemsg));
40 printf("error code %d\n", error);
44 bzero(&sleepmsg, sizeof(sleepmsg));
45 sleepmsg.usrmsg.umsg.ms_cmd = SYS_nanosleep;
46 sleepmsg.usrmsg.umsg.ms_flags = MSGF_ASYNC;
50 ts1.tv_nsec = 500 * 1000000;
51 error = sendsys(NULL, &sleepmsg.usrmsg, sizeof(sleepmsg));
52 printf("error code %d\n", error);
53 if (error == EASYNC) {
54 struct nanosleep_args *rmsg;
56 printf("error %d is async return, waiting...", EASYNC);
59 rmsg = (void *)sendsys(NULL, NULL, -1);
60 printf(" rmsg %p\n", rmsg);
61 if (rmsg == &sleepmsg)
65 printf("async return error %d\n", sleepmsg.usrmsg.umsg.ms_error);
67 printf("error %d\n", error);