From f9cf89d54f0d1661fd78f778d0bdb4812f3bd460 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 24 Oct 2017 23:35:21 +0200 Subject: 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 Signed-off-by: Sander Vrijders --- src/lib/dev.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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); -- cgit v1.2.3