monado/src/xrt/auxiliary/util/u_process.h
Christoph Haag 4ea68b89a4 xrt: Add u_process, backed by libbsd's pidfile
Delete stale ipc files in ipc server when not already running.

If built without libbsd, fall back to previous behavior of complaining about existing ipc files and exit.
2021-04-15 21:42:06 +00:00

43 lines
929 B
C

// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Simple process handling
* @author Christoph Haag <christoph.haag@collabora.com>
* @ingroup aux_util
*/
#pragma once
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
struct u_process;
/*!
* Creates a handle for this process that is unique to the operating system user. Returns NULL if another process
* holding a handle is already running.
*
* @todo If built without libbsd support, a dummy value is returned that needs to be handled by the caller.
*
* @return a new u_process handle if no monado instance is running, NULL if another instance is already running.
* @ingroup aux_util
*/
struct u_process *
u_process_create_if_not_running();
/*!
* Releases the unique handle of the operating system user.
*
* @ingroup aux_util
*/
void
u_process_destroy(struct u_process *proc);
#ifdef __cplusplus
}
#endif