diff options
author | Dimitri Staessens <dimitri.staessens@ugent.be> | 2017-10-24 23:35:21 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-10-25 09:53:50 +0200 |
commit | f9cf89d54f0d1661fd78f778d0bdb4812f3bd460 (patch) | |
tree | ac3c689be6e44c15bbb2204094490216da422cf3 /src | |
parent | 351da36fb339b56b95cff52ff5d0da1ad8e20def (diff) | |
download | ouroboros-f9cf89d54f0d1661fd78f778d0bdb4812f3bd460.tar.gz ouroboros-f9cf89d54f0d1661fd78f778d0bdb4812f3bd460.zip |
dev: Bind python scripts to script name
This revises the library init script so that it checks whether the
program is run by a python executable (python, python2 or python3) and
announces the script name instead of the python interpreter. This
enables binding python scripts.
Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/dev.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index e216baab..11ab645d 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -595,6 +595,16 @@ static int flow_init(int port_id, return fd; } +static bool check_python(char * str) +{ + if (!strcmp(path_strip(str), "python") || + !strcmp(path_strip(str), "python2") || + !strcmp(path_strip(str), "python3")) + return true; + + return false; +} + __attribute__((constructor)) static void init(int argc, char ** argv, char ** envp) @@ -608,6 +618,9 @@ __attribute__((constructor)) static void init(int argc, assert(ai.ap_name == NULL); + if (check_python(argv[0])) + ap_name = argv[1]; + ai.api = getpid(); ai.fds = bmp_create(AP_MAX_FLOWS - AP_RES_FDS, AP_RES_FDS); |