Mercurial > hg > Members > aka > jupyter_CbC_kernel
comparison jupyter_c_kernel/resources/master.c @ 73:b6b613c2a28a
alter package structure, moving resources under parent module.
author | Cody Horst <chorst@uw.edu> |
---|---|
date | Tue, 23 Jan 2018 22:34:24 -0800 |
parents | resources/master.c@7857f8eea835 |
children | a1e3b056a4bd |
comparison
equal
deleted
inserted
replaced
72:40c903dde893 | 73:b6b613c2a28a |
---|---|
1 #include <stdlib.h> | |
2 #include <stdio.h> | |
3 #include <dlfcn.h> | |
4 | |
5 typedef int (*main_t)(int, char **, char **); | |
6 | |
7 int main(int argc, char **argv, char **envp) | |
8 { | |
9 char *error = NULL; | |
10 | |
11 setbuf(stdout, NULL); | |
12 setbuf(stderr, NULL); | |
13 if (argc < 2) { | |
14 fprintf(stderr, "USAGE: %s PROGRAM\nWhere PROGRAM is the user's program to supervise\n", argv[0]); | |
15 return EXIT_FAILURE; | |
16 } | |
17 void *userhandle = dlopen(argv[1], RTLD_LAZY); | |
18 if (userhandle == NULL) { | |
19 fprintf(stderr, "%s: %s\n", argv[0], dlerror()); | |
20 return EXIT_FAILURE; | |
21 } | |
22 dlerror(); | |
23 main_t usermain = dlsym(userhandle, "main"); | |
24 if ((error = dlerror()) != NULL) { | |
25 fprintf(stderr, "%s: %s\n", argv[0], error); | |
26 return EXIT_FAILURE; | |
27 } | |
28 | |
29 /* Call Users main, but make master.c invisible by removing first argument */ | |
30 return usermain(argc-1, argv+1, envp); | |
31 } |