minishell 허용함수 목록 - gachi-mandoo-shell/Docs GitHub Wiki
- int printf(const char *format, ...);
- #incldue <stdio.h>
- void *malloc(size_t size);
- #include <stdlib.h>
- void free(void *ptr);
- #include <stdlib.h>
- ssize_t write(int fd, const void *buf, size_t count);
- #include <unistd.h>
- int open(const char *pathname, int flags);
- #include <sys/stat.h>
- #include <fcntl.h>
- ssize_t read(int fd, void *buf, size_t count);
- #include <unistd.h>
- int close(int fd);
- #include <unistd.h>
- pid_t fork(void);
- #include <unistd.h>
- 프로세스를 호출하고자 할 때 사용
- pid_t wait(int *wstatus);
- #include <sys/wait.h>
- 자식 프로세스가 종료 될 때까지 기다릴 수 있다.
- pid_t waitpid(pid_t pid, int *wstatus, int options);
- #include <sys/wait.h>
- 기다릴 자식 프로세스를 좀 더 상세히 지정할 수 있음
- pid_t wait3(int *wstatus, int options, struct rusage *rusage);
- #include <sys/types.h>
- #include <sys/time.h>
- #include <sys/resource.h>
- #include <sys/wait.h>
- 사용자 시간 정보를 확인 할 수 있음
- pid_t wait4(pid_t pid, int *wstatus, int options,struct rusage *rusage);
- #include <sys/types.h>
- #include <sys/time.h>
- #include <sys/resource.h>
- #include <sys/wait.h>
- 해당 pid만을 기다림
- void *signal(int signum, void (*handler) (int))) (int);
- #include <signal.h>
- signal : 프로세스 인터럽트
- signum의 종류에 따라 handler를 설정해 줄 수 잇다.
- int kill(pid_t pid, int sig);
- #include <signal.h>
- 쉘에서 프로세스를 죽이는 역할을 함
- 특정 pid에 sig가 발생하면 그 프로세스를 중단시킨다.
- void exit(int status);
- #include <stdlib.h>
- 프로그램 정상종료
- int stat(const char *path, struct stat *buf);
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- path 경로에 있는 파일의 정보를 stat 구조체에 받아온다
- int lstat(const char *path, struct stat *buf);
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- symbolic link인 파일을 path로 넘기면 symblic link인 파일 자체의 정보를 stat 구조체에 받아온다.
- int fstat(int fd, struct stat *buf);
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- 열려진 파일(fd)의 정보를 stat 구조체에 받아온다.
- int execve(const char *filename, char *const argv[], char *const envp[]);
- #include <unistd.h>
- 실행 가능한 파일인 filename의 실행코드를 현재 프로세스에 적재하여 실행시킨다.
- argv : filename에 들어가는 인자목록, envp : 환경변수 목록
- int dup(int fd);
- #include <unistd.h>
- 파일 디스크립터를 복제하는 함수
- int dup2(int fd, int fd2);
- #include <unistd.h>
- fd2가 fd를 복제한다
- int pipe(int fd[2])
- #include <unistd.h>
- 독립된 프로세스들이 데이터를 주고 받을 수 있게 된다.
- fd[1] : 쓰기용 파이프, fd[0] : 읽기용 파이프
- char *getcwd(char *buf, size_t size);
- #include <unistd.h>
- 현재 작업중인 디렉토리의 경로를 얻는다.
- buf에 size만큼 얻어옴 (버퍼가 작을 경우 에러가 발생할 수 있으므로 크게 잡는다.)
- int chdir(const char *path);
- #include <unistd.h>
- 작업 디렉토리를 변경
- DIR *opendir(const char *name)
- #include <dirent.h>
- 디렉토리 열기를 성고하면 디렉토리 정보 구조체인 dir포인터를 반환
- struct dirent *readdir(DIR *dir)
- #include <dirent.h>
- opendir에서 연 디렉토리의 정보를 struct dirent*로 반환해준다.
- int closedir(DIR *dir)
- #include <dirent.h>
- opendir로 디렉토리를 열었다면, 파일 처럼 closedir을 해주어야 한다.
- char *strerror(int errnum);
- #include <string.h>
- errnum을 설명하는 에러 메세지를 반환해준다.
- errno
- #include <errno.h>
- 자동으로 발생된 에러에 대한 번호가 저장됨
- int isatty(int fd);
- #include <unistd.h>
- 파일 지정자(fd)가 터미널에 연결되어 있는지 확인
- isatty(0) : 표준입력으로 터미널에 연결
- char *ttyname(int fd);
- #include <unistd.h>
- fd에 연결되어 있는 터미널의 이름을 리턴해준다.
- int ttyslot(void);
- #include <unistd.h>
- 디바이스 파일이 발견되면 유닛번호를 반환해준다.
- 디바이스 파일 : 소프트웨어가 장치 드라이버와 상호 작용할 수 있게 해주는 파일(/dev/ 위치에 있다.)
- 유닛번호 : ?
- int ioctl(int d, int request, ...);
- #include <sys/ioctl.h>
- 장치에 접근해서 장치 정보를 얻거나, 장치의 값을 변경하기 위한 용도로 사용
- 우리는 파일 지정자를 넘겨 파일에 대한 정보를 request(버퍼)에 담아올 것
- char *getenv(const char *name);
- #include <stdlib.h>
- name이 가리키는 환경변수를 찾아 그 값에 대한 포인터를 반환
- int tcsetattr(int fildes, int optional_actions, const struct termios *termios_p);
- #include <termios.h>
- 터미널 파일 fildes에 대한 터미널 속성을 설정
- termios_p : 터미널 속성을 저장할 주소
- int tcgetattr(int fildes, struct termios *termios_p);
- #include <termios.h>
- 터미널 파일 fildes에 대한 속성을 얻어 termios_p에 저장한다.
(터미널 관련 정보를 받아오는 함수라고 추측중... ㅜ)
- int tgetent(const char *bp, char *name);
- #include <curses.h>
- #include <term.h>
- int tgetflag(const char *id);
- #include <curses.h>
- #include <term.h>
- int tgetnum(const char *id);
- #include <curses.h>
- #include <term.h>
- char *tgetstr(const char *id, char **area);
- #include <curses.h>
- #include <term.h>
- char tgoto(const char cap, int col, int row);
- #include <curses.h>
- #include <term.h>
- int tputs(const char *str, int affcnt, int (*putc(int));
- #include <curses.h>
- #include <term.h>