progress: make gmsh great again
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#ifndef _JOB_H_
|
||||
#define _JOB_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MAX_ARGS 64
|
||||
|
||||
// [1단계] 단일 명령어 (Simple Command)
|
||||
// 예: "grep error > log.txt"
|
||||
typedef struct command_t {
|
||||
char *argv[MAX_ARGS]; // 인자 리스트 (예: {"grep", "error", NULL})
|
||||
int argc; // 인자 개수
|
||||
|
||||
char *input_path; // 리다이렉션 < (없으면 NULL)
|
||||
char *output_path; // 리다이렉션 > (없으면 NULL)
|
||||
int append_mode; // >> 모드 여부 (0 or 1)
|
||||
|
||||
struct command_t *next; // 파이프라인의 다음 명령어 (Linked List)
|
||||
} command_t;
|
||||
|
||||
// [2단계] 작업 상태 (Job State)
|
||||
typedef enum {
|
||||
JOB_RUNNING, // 실행 중
|
||||
JOB_STOPPED, // 정지됨 (Ctrl+Z)
|
||||
JOB_DONE // 완료됨
|
||||
} job_state_t;
|
||||
|
||||
// [3단계] 작업 (Job) - 파이프라인 전체를 하나의 작업으로 봄
|
||||
// 예: "ls | grep c &"
|
||||
typedef struct job_t {
|
||||
int id; // Job ID (쉘이 관리하는 번호: 1, 2, 3...)
|
||||
pid_t pgid; // Process Group ID (이 작업의 대표 PID)
|
||||
job_state_t state; // 현재 상태
|
||||
int is_bg; // 백그라운드 실행 여부 (1=BG, 0=FG)
|
||||
char *command_line; // 원본 명령어 문자열 (jobs 출력용)
|
||||
|
||||
command_t *head; // 명령어 리스트의 첫 번째 (ls)
|
||||
|
||||
struct job_t *next; // 다음 작업 (Job List용)
|
||||
} job_t;
|
||||
|
||||
// --- 함수 원형 ---
|
||||
|
||||
// Job 관리
|
||||
void init_job_list();
|
||||
job_t *create_job(char *line);
|
||||
void add_job(job_t *job);
|
||||
int delete_job(pid_t pgid);
|
||||
job_t *find_job(pid_t pgid);
|
||||
job_t *find_job_by_id(int id);
|
||||
void free_job(job_t *job);
|
||||
|
||||
// Command 관리
|
||||
void append_command(job_t *job, command_t *cmd);
|
||||
void free_command(command_t *cmd);
|
||||
|
||||
// 전역 변수 (외부에서 접근 가능)
|
||||
extern job_t *job_list_head;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user