/*
- Copyright 2018 IoT.bzh
+ Copyright (C) 2015-2020 IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
limitations under the License.
*/
-#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
#include <systemd/sd-daemon.h>
+extern char **environ;
+
int main()
{
- sigset_t ass, bss;
-
- sigemptyset(&ass);
- sigaddset(&ass, SIGTERM);
-
- sigfillset(&bss);
- sigdelset(&bss, SIGTERM);
+ char buffer[100];
+ char *args[] = { "/bin/systemctl", "--wait", "start", buffer, 0 };
+ sprintf(buffer, "afm-user-session@%d.target", (int)getuid());
sd_notify(0, "READY=1");
- sigprocmask(SIG_SETMASK, &bss, 0);
- sigwaitinfo(&ass, 0);
-
- return 0;
+ execve(args[0], args, environ);
+ return 1;
}