#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <wait.h>
#include <string.h>
#include <signal.h>
#define MAX_LINE 80 /* 80 chars per line, per command, should be enough. */
#define BUFFERSIZE 11
typedef struct{
int number;
char com[MAX_LINE];
}command;
command buffer[BUFFERSIZE];
int buffer_pointer;
int setup(char inputBuffer[], char *args[],int *background);
void print(){
int i;
fflush(stdout);
write(STDOUT_FILENO,"\n",1);
for(i = (buffer_pointer - 1) % BUFFERSIZE;\
i != (buffer_pointer % BUFFERSIZE) && buffer[i].number;\
i = (i - 1 + BUFFERSIZE) % BUFFERSIZE ){
printf("%d\t%s",buffer[i].number,buffer[i].com);
fflush(stdout);
}
}
void handle_SIGINT(){
print();
signal(SIGINT, SIG_IGN);
return;
}
/**
* setup() reads in t
操作系统编程作业:UNIX Shell and History Feature
最新推荐文章于 2021-05-17 11:27:33 发布