40fa982cb9ee37ecae0fd7de3ee4e9fd946c619e
[dpdk.git] / lib / librte_eal / common / eal_common_proc.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016 Intel Corporation
3  */
4
5 #include <stdio.h>
6 #include <fcntl.h>
7 #include <stdlib.h>
8 #include <rte_eal.h>
9
10 #include "eal_filesystem.h"
11 #include "eal_internal_cfg.h"
12
13 int
14 rte_eal_primary_proc_alive(const char *config_file_path)
15 {
16         int config_fd;
17
18         if (config_file_path)
19                 config_fd = open(config_file_path, O_RDONLY);
20         else {
21                 const char *path;
22
23                 path = eal_runtime_config_path();
24                 config_fd = open(path, O_RDONLY);
25         }
26         if (config_fd < 0)
27                 return 0;
28
29         int ret = lockf(config_fd, F_TEST, 0);
30         close(config_fd);
31
32         return !!ret;
33 }