File: pctl.h

package info (click to toggle)
swupdate 2025.12%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 10,004 kB
  • sloc: ansic: 66,621; python: 6,291; makefile: 791; sh: 538; javascript: 229
file content (56 lines) | stat: -rw-r--r-- 1,463 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * (C) Copyright 2016-2023
 * Stefano Babic <stefano.babic@swupdate.org>
 *
 * SPDX-License-Identifier:     GPL-2.0-only
 */

#pragma once

#include <swupdate_status.h>
#include <sys/types.h>
#include "util.h"

extern int pid;
extern int sw_sockfd;

/*
 * This is used by the core process
 * to monitor all derived processes
 */
struct swupdate_task {
	pid_t	pid;
	int	pipe;
	sourcetype	type;
	const char	*name;
};

pthread_t start_thread(void *(* start_routine) (void *), void *arg);

void thread_ready(void);
void wait_threads_ready(void);

typedef int (*swupdate_process)(const char *cfgname, int argc, char **argv);
typedef server_op_res_t(*server_ipc_fn)(int fd);

void start_subprocess(sourcetype type, const char *name,
			uid_t run_as_userid, gid_t run_as_groupid,
			const char *cfgfile,
			int argc, char **argv,
			swupdate_process start);

void start_subprocess_from_file(sourcetype type, const char *name,
			uid_t run_as_userid, gid_t run_as_groupid,
			const char *cfgfile,
			int argc, char **argv,
			const char *cmd);
/* ipc_thread listens to pctl IPC socket and call server specific function */
void *ipc_thread_fn(void *data);

void sigchld_handler (int __attribute__ ((__unused__)) signum);

int pctl_getfd_from_type(sourcetype s);
const char *pctl_getname_from_type(sourcetype s);
int run_system_cmd(const char *cmd);
int run_system_cmd_with_fdin(const char *cmd, int *fdin);
int run_function_background(void *fn, int argc, char **argv);