view resources/master.c @ 42:778218c42d18

Make step-by-step installation less error prone The pip install is now made before we clone (so we always install from PyPi) and the Git clone is made via HTTPS not SSH in case you do not have your SSH key on your GH account
author Brendan Rius <brendan.rius@gmail.com>
date Wed, 08 Jun 2016 10:34:02 +0100
parents 8acbab5a9f21
children 7857f8eea835
line wrap: on
line source

#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

typedef int (*main_t)(int, char **, char **);

int main(int argc, char **argv, char **envp)
{
    char *error = NULL;

    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
    if (argc < 2) {
        fprintf(stderr, "USAGE: %s PROGRAM\nWhere PROGRAM is the user's program to supervise\n", argv[0]);
        return EXIT_FAILURE;
    }
    void *userhandle = dlopen(argv[1], RTLD_LAZY);
    if (userhandle == NULL) {
        fprintf(stderr, "%s: %s\n", argv[0], dlerror());
        return EXIT_FAILURE;
    }
    dlerror();
    main_t usermain = dlsym(userhandle, "main");
    if ((error = dlerror()) != NULL) {
        fprintf(stderr, "%s: %s\n", argv[0], error);
        return EXIT_FAILURE;
    }
    return usermain(argc, argv, envp);
}