X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafm-urun.c;h=0249a6077dcc13fc0081b678eb4602ba645379ab;hb=fec10d1a986a807df4c6fa27d848199399806236;hp=d242df80930bbcebf9c1cf90b16456cb28e42e8c;hpb=1b079c90ed954cca65a7b07d5480e75d46217b85;p=src%2Fapp-framework-main.git diff --git a/src/afm-urun.c b/src/afm-urun.c index d242df8..0249a60 100644 --- a/src/afm-urun.c +++ b/src/afm-urun.c @@ -1,5 +1,5 @@ /* - Copyright 2015, 2016, 2017 IoT.bzh + Copyright (C) 2015-2018 IoT.bzh author: José Bollo @@ -424,3 +424,26 @@ end: return result; } +/* + * Search the runid, if any, of the application of 'id' for the user 'uid'. + * Returns the pid (a positive not null number) or -1 in case of error. + */ +int afm_urun_search_runid(struct afm_udb *db, const char *id, int uid) +{ + int isuser, pid; + const char *udpath; + struct json_object *appli; + + appli = afm_udb_get_application_private(db, id, uid); + if (!appli) { + NOTICE("Unknown appid %s", id); + errno = ENOENT; + pid = -1; + } else if (get_basis(appli, &isuser, &udpath, 0, uid) < 0) { + pid = -1; + } else { + pid = systemd_unit_pid_of_dpath(isuser, udpath); + } + return pid; +} +