Commit a14ec0c0 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk Committed by Adam Wujek

arch-wrs: start only if there is no other PPSi already running

Otherwise it breaks Minipc and wr_mon cannot start.
parent 12514c7c
......@@ -18,6 +18,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/timex.h>
#include <signal.h>
#include <minipc.h>
#include <hal_exports.h>
......@@ -86,6 +87,24 @@ int main(int argc, char **argv)
pp_printf("PPSi. Commit %s, built on " __DATE__ "\n",
/* check if there is another instance of PPSi already running */
ppsi_head = wrs_shm_get(wrs_shm_ptp, "", WRS_SHM_READ);
if (!ppsi_head) {
pp_printf("Unable to open shm for PPSi! Unable to check if "
"there is another PPSi instance running. Error: %s\n",
/* check if pid is 0 (shm not filled) or process with provided
* pid does not exist (probably crashed) */
if ((ppsi_head->pid != 0) && (kill(ppsi_head->pid, 0) == 0)) {
pp_printf("Fatal: There is another PPSi instance running. "
/* try connecting to HAL multiple times in case it's still not ready */
hal_retries = WRSW_HAL_RETRIES;
while (hal_retries) { /* may be never, if built without WR extension */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment