Mercurial > hg > Members > aka > jupyter_CbC_kernel
comparison jupyter_c_kernel/resources/master.c @ 75:a1e3b056a4bd 1.2.2
Merge pull request #40 from halfhorst/master
add resources/ as package data
committer: GitHub <noreply@github.com>
author | Brendan Rius <brendan.rius@gmail.com> |
---|---|
date | Wed, 24 Jan 2018 11:01:54 +0100 |
parents | resources/master.c@7857f8eea835 resources/master.c@b6b613c2a28a |
children |
comparison
equal
deleted
inserted
replaced
70:eec68d0a113e | 75:a1e3b056a4bd |
---|---|
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 } |