Fix directory hierarchy & cmake configuration files
[platform/core/appfw/launchpad.git] / src / lib / launchpad-hydra / src / launchpad_sigchld.c
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #define _GNU_SOURCE
18 #include <errno.h>
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <sys/types.h>
22
23 #include "launchpad_sigchld.h"
24 #include "launchpad_socket.h"
25 #include "log_private.h"
26
27 #define HYDRA_SIGCHLD_SOCK ".hydra-sigchld-sock"
28
29 int _sigchld_send(int pid)
30 {
31         socket_h sock;
32         char path[LAUNCHPAD_SOCKET_PATH_SIZE];
33         int ret;
34
35         if (pid <= 1) {
36                 _E("Invalid parameter");
37                 return -EINVAL;
38         }
39
40         snprintf(path, sizeof(path), "/run/aul/daemons/%u/%s",
41                         getuid(), HYDRA_SIGCHLD_SOCK);
42         ret = _socket_create(path, true, &sock);
43         if (ret < 0)
44                 return ret;
45
46         ret = _socket_send(sock, &pid, sizeof(pid));
47         _socket_destroy(sock);
48
49         return ret;
50 }