labwc/include/common/spawn.h

49 lines
1.1 KiB
C
Raw Normal View History

2021-11-13 21:56:53 +00:00
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_SPAWN_H
#define LABWC_SPAWN_H
2020-08-03 20:56:38 +01:00
2025-09-18 12:49:45 +02:00
#include <stdbool.h>
2024-03-18 06:15:15 +01:00
#include <sys/types.h>
2025-09-18 12:49:45 +02:00
/**
* set_cloexec - set file descriptor to close on exit
* @fd: file descriptor
*/
bool set_cloexec(int fd);
/**
* spawn_primary_client - execute asynchronously
* @command: command to be executed
*/
pid_t spawn_primary_client(const char *command);
2020-08-03 20:56:38 +01:00
/**
2024-03-08 21:59:20 +09:00
* spawn_async_no_shell - execute asynchronously
2020-08-03 20:56:38 +01:00
* @command: command to be executed
*/
void spawn_async_no_shell(char const *command);
2024-03-18 06:15:15 +01:00
/**
* spawn_piped - execute asynchronously
2024-03-18 06:15:15 +01:00
* @command: command to be executed
* @pipe_fd: set to the read end of a pipe
* connected to stdout of the command
*
* Notes:
* The returned pid_t has to be waited for to
* not produce zombies and the pipe_fd has to
* be closed. spawn_piped_close() can be used
* to ensure both.
*/
pid_t spawn_piped(const char *command, int *pipe_fd);
/**
* spawn_piped_close - clean up a previous
* spawn_piped() process
* @pid: will be waitpid()'d for
* @pipe_fd: will be close()'d
*/
void spawn_piped_close(pid_t pid, int pipe_fd);
#endif /* LABWC_SPAWN_H */