陈越 3 lat temu
rodzic
commit
eb0d503718
6 zmienionych plików z 31 dodań i 24 usunięć
  1. +1
    -7
      fun.h
  2. +5
    -1
      fun_1.c
  3. +10
    -2
      fun_2.c
  4. BIN
      main
  5. +13
    -8
      main.c
  6. +2
    -6
      mytop.c

+ 1
- 7
fun.h Wyświetl plik

@ -1,15 +1,9 @@
#ifndef FUN_H_INCLUDED
#define FUN_H_INCLUDED
#define MAXLINE (80)
#define MAXLINE (80)
#include "fun_2.c"
#include "fun_1.c"
//void history(char *cmdline);
//void print_his(char *argv);
//void eval(char *cmdline);
//int parseline(const char *cmdline, char **argv);
#endif // FUN_H_INCLUDED

+ 5
- 1
fun_1.c Wyświetl plik

@ -5,7 +5,11 @@
#include<fcntl.h>
#include "mytop.c"
//#include "fun.h"
int parseline(const char *cmdline, char **argv);
int builtin_cmd(char **argv);
int dup2(int fd, int arg);
int chdir(const char *path );
void eval(char *cmdline)
{

+ 10
- 2
fun_2.c Wyświetl plik

@ -1,7 +1,15 @@
#include <string.h>
#include<fcntl.h>
//#include "fun.h"
#include<fcntl.h>
void history(char *cmdline);
void print_his(char *argv);
int pipe(int *fd);
int fork();
int close(int arg);
int dup(int fd);
int execvp(const char* command, char* argv[]);
int wait(int arg);
static int num = 0;
static char storage[MAXLINE][MAXLINE];

BIN
main Wyświetl plik


+ 13
- 8
main.c Wyświetl plik

@ -1,15 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include "fun.h"
void eval(char *cmdline);
void sigint_handler();
pid_t getpid(void);
pid_t main_proc_pid;
void sigint_handler()
{
pid_t pid = getpid();
if(pid != main_proc_pid)
{
exit(0);
}
}
int main()
{
@ -26,4 +22,13 @@ int main()
history(cmdline);
}
return 0;
}
void sigint_handler()
{
pid_t pid = getpid();
if(pid != main_proc_pid)
{
exit(0);
}
}

+ 2
- 6
mytop.c Wyświetl plik

@ -1,5 +1,4 @@
//#define mytop_h
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
@ -313,13 +312,10 @@ void get_procs(void)
void getkinfo(void)
{
FILE *fp;
if ((fp = fopen("/proc/kinfo", "r")) == NULL) {
exit(1);
}
if (fscanf(fp, "%u %u", &nr_procs, &nr_tasks) != 2) {
if (fscanf(fp, "%u %u", &nr_procs, &nr_tasks) != 2) {
exit(1);
}
fclose(fp);
@ -338,4 +334,4 @@ void mytop()
get_procs();
print_procs(prev_proc,proc,1);
return;
}
}

Ładowanie…
Anuluj
Zapisz