aboutsummaryrefslogtreecommitdiff
path: root/include/job.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/job.h')
-rw-r--r--include/job.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/include/job.h b/include/job.h
new file mode 100644
index 0000000..cbd9b30
--- /dev/null
+++ b/include/job.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+#include "setting.h"
+
+#define MAXLINE 1024 /* max line size */
+#define MAXARGS 128 /* max args on a command line */
+#define MAXJOBS 16 /* max jobs at any point in time */
+#define MAXJID 1<<16 /* max job ID */
+
+#define UNDEF 0 /* undefined */
+#define FG 1 /* running in foreground */
+#define BG 2 /* running in background */
+#define ST 3 /* stopped */
+
+
+namespace ov4
+{
+
+extern struct job_t jobs[];
+extern int nextjid;
+
+struct job_t { /* The job struct */
+ pid_t pid; /* job PID */
+ int jid; /* job ID [1, 2, ...] */
+ int state; /* UNDEF, BG, FG, or ST */
+ char cmdline[MAXLINE]; /* command line */
+};
+
+void clearjob(struct job_t *job);
+void initjobs(struct job_t *jobs);
+int maxjid(struct job_t *jobs);
+int addjob(struct job_t *jobs, pid_t pid, int state, char *cmdline);
+int deletejob(struct job_t *jobs, pid_t pid);
+pid_t fgpid(struct job_t *jobs);
+struct job_t *getjobpid(struct job_t *jobs, pid_t pid);
+struct job_t *getjobjid(struct job_t *jobs, int jid);
+int pid2jid(pid_t pid);
+void listjobs(struct job_t *jobs);
+bool job_suspend(struct job_t *jobs, pid_t pid);
+
+}