1: /*
2: * $Id: jobtab.h,v 1.3 2025/03/09 19:14:25 snw Exp $
3: * job table structures
4: *
5: *
6: * Author: Serena Willis <snw@coherent-logic.com>
7: * Copyright (C) 1998 MUG Deutschland
8: * Copyright (C) 2021, 2025 Coherent Logic Development LLC
9: *
10: *
11: * This file is part of FreeM.
12: *
13: * FreeM is free software: you can redistribute it and/or modify
14: * it under the terms of the GNU Affero Public License as published by
15: * the Free Software Foundation, either version 3 of the License, or
16: * (at your option) any later version.
17: *
18: * FreeM is distributed in the hope that it will be useful,
19: * but WITHOUT ANY WARRANTY; without even the implied warranty of
20: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: * GNU Affero Public License for more details.
22: *
23: * You should have received a copy of the GNU Affero Public License
24: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
25: *
26: * $Log: jobtab.h,v $
27: * Revision 1.3 2025/03/09 19:14:25 snw
28: * First phase of REUSE compliance and header reformat
29: *
30: *
31: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
32: * SPDX-License-Identifier: AGPL-3.0-or-later
33: **/
34:
35: #if !defined(_FREEM_JOBTAB_H)
36: # define _FREEM_JOBTAB_H
37:
38: #if defined(__APPLE__)
39: # include <sys/time.h>
40: #endif
41:
42: #define JFLG_DAEMON 1
43: #define JFLG_NEW 2
44: #define JFLG_ALIVE 4
45: #define JFLG_DEFUNCT 8
46: #define JFLG_REPLSENDER 16
47: #define JFLG_REPLRECEIVER 32
48: #define JFLG_FMADM 64
49:
50: #define JSTAT_IDLE 0
51: #define JSTAT_INTERPRETER 1
52: #define JSTAT_HOUSEKEEPING 2
53: #define JSTAT_DIRECTMODE 3
54: #define JSTAT_ERROR 4
55: #define JSTAT_SHUTDOWN 5
56:
57: #define JIPCFLG_PENDING 0
58: #define JIPCFLG_RECEIVED 1
59:
60: typedef struct ipc_slot_t {
61:
62: /* PID of sender */
63: pid_t sender_pid;
64:
65: /* IPC flags */
66: unsigned short flags;
67:
68: void *object;
69:
70: struct ipc_slot_t *next;
71:
72: } ipc_slot_t;
73:
74: typedef struct job_slot_t {
75:
76: /* process ID */
77: pid_t pid;
78:
79: /* job flags */
80: unsigned short flags;
81:
82: /* job status */
83: unsigned short status;
84:
85: /* first IPC slot */
86: ipc_slot_t *ipc_head;
87:
88: /* timestamp at start */
89: time_t start_time;
90:
91: /* stop requested */
92: pid_t stop_requested;
93:
94: /* last error value */
95: char last_ecode[20];
96:
97: /* next slot */
98: struct job_slot_t *next;
99:
100: } job_slot_t;
101:
102: extern short jobtab_get_sem(void);
103: extern void jobtab_release_sem(void);
104: extern void jobtab_init(void);
105: extern job_slot_t *job_init(short is_fmadm);
106: extern void job_remove(const pid_t pid);
107: extern void job_request_stop(const pid_t target_pid);
108: extern void job_set_ecode(const pid_t target_pid, const char *ecode);
109: extern pid_t job_stop_requested (const pid_t target_pid);
110: extern void job_request_all_stop(void);
111: extern void job_signal_all(const int sig);
112: extern int job_count(void);
113: extern job_slot_t *job_set_status(const pid_t target_pid, const unsigned short status);
114: extern void job_gc_mark(void);
115: extern void job_gc_sweep(void);
116: extern ipc_slot_t *job_send_ipc(const pid_t receiver_pid, const void *object);
117: extern job_slot_t *job_get(const pid_t target_pid);
118: extern void job_dump(void);
119:
120: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>