代码拉取完成,页面将自动刷新
//
// Created by zavier on 2021/7/18.
//
#ifndef WISH_JOBS_H
#define WISH_JOBS_H
#include <unistd.h>
#include <iostream>
#include <string>
#include <vector>
#include <list>
class Jobs {
public:
enum JobState{
UNDEFINE, //未定义
BACKGROUND,//后台任务
FOREGROUND, //前台任务
STOP //暂停任务
};
struct Job{
pid_t pid; /* job PID */
int jid; /* job ID [1, 2, ...] */
int state; /* UNDEF, BG, FG, or ST */
std::string cmd; /* command line */
};
Jobs(){
nextJid=1;
jobs.resize(JOBSIZE);
for(auto &job:jobs){
clearJob(job);
}
}
bool addJob(pid_t pid,int state,const std::string &cmd);
bool deleteByPid(pid_t pid);
bool deleteByJid(int jid);
Job* getJobBypid(pid_t pid);
Job* getJobByJid(int jid);
Job* getForegroundJob();
pid_t getForegroundJobPid();
void printJobs();
size_t size();
int maxJid();
friend std::ostream &operator<<(std::ostream &os,Jobs);
private:
static constexpr int JOBSIZE=100;
int nextJid;
size_t currentJobs;
std::vector<Job> jobs;
void clearJob(Job &job);
};
#endif //WISH_JOBS_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。