aboutsummaryrefslogtreecommitdiffstats
path: root/src/afm-urun.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-12-18 12:26:41 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2018-01-19 10:08:08 +0100
commitbd910c758e234e165f6a3239c14e77f53d1fc480 (patch)
treeef4a6ac3bf3e9eb84ccce958b0b0376a2b48935e /src/afm-urun.c
parent66817a088f7b3ccd85117bfe6a610710a728ef09 (diff)
afm-binding: Allow use of appid instead of runid
This facility avoid the double call 'ps', 'kill' and allow a single call to 'kill' with the application id. Bug-AGL: SPEC-1189 Change-Id: I71861c06847e855b05dc8294ab1ea6785f555416 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afm-urun.c')
-rw-r--r--src/afm-urun.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/afm-urun.c b/src/afm-urun.c
index d242df8..36f40b2 100644
--- a/src/afm-urun.c
+++ b/src/afm-urun.c
@@ -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;
+}
+