mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
job control: sessions and process groups
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#ifndef _JOBCTL_H
|
||||
#define _JOBCTL_H
|
||||
|
||||
#include <kernel/scheduler.h>
|
||||
|
||||
int jobctl_newsession(proc_t *proc);
|
||||
int jobctl_newgroup(proc_t *proc);
|
||||
int jobctl_changegroup(proc_t *proc, proc_t *group);
|
||||
void jobctl_detach(proc_t *);
|
||||
void jobctl_addproc(proc_t *parent, proc_t *proc);
|
||||
void jobctl_procremove(proc_t *proc);
|
||||
pid_t jobctl_getpgid(proc_t *proc);
|
||||
pid_t jobctl_getsid(proc_t *proc);
|
||||
void jobctl_setctty(proc_t *proc, void *ctty);
|
||||
void *jobctl_getctty(proc_t *proc);
|
||||
|
||||
#endif
|
||||
@@ -74,6 +74,29 @@ typedef struct proc_t {
|
||||
semaphore_t waitsem;
|
||||
spinlock_t exiting;
|
||||
bool nomorethreads;
|
||||
|
||||
spinlock_t jobctllock;
|
||||
struct {
|
||||
// NULL if this process is leader
|
||||
struct proc_t *leader;
|
||||
|
||||
// these are only applicable if the process is leader
|
||||
struct proc_t *foreground; // process group leader, NULL if self
|
||||
void *controllingtty;
|
||||
int processcount; // refcount
|
||||
} session;
|
||||
|
||||
struct {
|
||||
// NULL if this process is leader
|
||||
struct proc_t *leader;
|
||||
// linked list
|
||||
struct proc_t *nextmember;
|
||||
struct proc_t *previousmember;
|
||||
|
||||
// these are only applicable if the process is leader
|
||||
spinlock_t lock; // protects the linked list
|
||||
int processcount; // refcount
|
||||
} pgrp;
|
||||
} proc_t;
|
||||
|
||||
#include <arch/cpu.h>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <termios.h>
|
||||
#include <kernel/poll.h>
|
||||
#include <ringbuffer.h>
|
||||
#include <kernel/vfs.h>
|
||||
|
||||
#define DEVICE_BUFFER_SIZE 512
|
||||
#define READ_BUFFER_SIZE 4096
|
||||
@@ -23,6 +24,7 @@ typedef struct {
|
||||
ttydevicewritefn_t writetodevice;
|
||||
int minor;
|
||||
winsize_t winsize;
|
||||
vnode_t *mastervnode;
|
||||
} tty_t;
|
||||
|
||||
void tty_init();
|
||||
|
||||
@@ -55,6 +55,7 @@ typedef struct vfs_t {
|
||||
#define V_FFLAGS_NONBLOCKING 4
|
||||
#define V_FFLAGS_SHARED 8
|
||||
#define V_FFLAGS_EXEC 16
|
||||
#define V_FFLAGS_NOCTTY 32
|
||||
|
||||
typedef struct vnode_t {
|
||||
struct vops_t *ops;
|
||||
|
||||
Reference in New Issue
Block a user