陈越 3 years ago
parent
commit
ed7add6585
5 changed files with 19 additions and 9 deletions
  1. +1
    -2
      fun_1.c
  2. +2
    -2
      fun_2.c
  3. BIN
      main
  4. +12
    -3
      main.c
  5. +4
    -2
      mytop.c

+ 1
- 2
fun_1.c View File

@ -7,13 +7,12 @@
#include "mytop.c"
//#include "fun.h"
void eval(char *cmdline)
{
char *argv[MAXLINE];
char buf[MAXLINE];
int isBg;
int pid;
pid_t pid;
strcpy(buf,cmdline);
isBg = parseline(cmdline,argv);
if(argv[0] == NULL)

+ 2
- 2
fun_2.c View File

@ -160,7 +160,7 @@ if(Isopen == '>')
int Is_redirect(char **argv)
{
int i = 0;
char Isopen = NULL;
char Isopen = '0';
char *cmd_0[MAXLINE];
char *cmd_1[MAXLINE];
while (argv[i]!=NULL)
@ -175,7 +175,7 @@ int Is_redirect(char **argv)
}
i++;
}
if(Isopen == NULL)
if(Isopen == '0')
{
return 0;
}

BIN
main View File


+ 12
- 3
main.c View File

@ -1,19 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include "fun.h"
pid_t main_proc_pid;
void sigint_handler()
{/*
pid_t pid = getpid();
if(pid != main_proc_pid)
{
exit(0);
}*/
}
int main()
{
char cmdline[MAXLINE];
main_proc_pid = getpid();
signal(SIGINT, sigint_handler);
while(1)
{
int bufsize = MAXLINE;
printf("COMMAND->");
fgets(cmdline, MAXLINE, stdin);
eval(cmdline);
history(cmdline);
}
return 0;
}
}

+ 4
- 2
mytop.c View File

@ -1,4 +1,4 @@
/*
#define mytop_h
#include <stdio.h>
#include <unistd.h>
@ -399,4 +399,6 @@ int mytop(){
//fflush(NULL);
return 0;
}
}
*/
int mytop(){}

Loading…
Cancel
Save