일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
- IT
- The Balance of the World
- 전자책
- 4949
- 10773
- system programming
- 5622
- c
- Process Communication
- QA
- 시스템 프로그래밍
- Baekjoon
- 1874
- BAKA
- 해바
- 브런치
- 균형잡힌 세상
- 입력 버퍼
- Zero That Out
- 바샤
- File 조작
- For Beginners
- Parenthesis
- 2941
- file IO
- 백준
- process control
- c++
- LJESNJAK
- 시프
- Today
- Total
목록process control (3)
해바
lab #9의 프로그램을 수정하여 다음의 프로그램을 작성하라 : 부모 프로세스는 자식 프로세스들의 종료를 기다리면서 종료하는 각 프로세스를 식별하여 메시지("Parent: First(또는 Second) Child: ")와 함께 종료 상태(status)를 출력하는 프로그램을 작성하라. // status.c #include #include #include #include int main() { int i = 0, status; pid_t pids[2]; while(pids[i] = fork()) { if(i + 1 == 2) break; ++i; } switch (pids[i]) { case -1: perror("fork"); case 0: switch (i) { case 0: execl("/bin/echo..
fork()와 wait()를 이용하여 다음의 프로그램을 작성하라 : 부모 프로세스는 두 개의 자식 프로세스를 생성한다 : Child 1, Child 2 각각의 자식 프로세스는 execl()을 이용하여 "echo" 커맨드를 실행하면서 "This is Child 1(또는 Child 2)"를 출력한다. 부모 프로세스는 wait() 를 실행하며 자식 프로세스들이 끝나기를 기다린다. wait()를 실행하기 전 "Parent: Waiting for children"하고 출력한다. 자식 프로세스들이 끝나면 부모는 "Parent: All Children terminated"하고 출력한다. // wait.c #include #include #include #include int main() { int i = 0, sta..
부모 프로세스는 sample.txt에 있는 문자열의 길이 만큼 자식 프로세스들을 생성한 후, waitpid 를 사용하여 생성된 순서대로 거두어 들이는 프로그램을 작성하라. 이 때 자식 프로세스는 자신의 순서만큼 문자열을 복사해서 output.txt에 작성하고 종료해야 한다. 결과 예시 sample.txt 내용 system // waitpid.c #include #include #include #include #include #include #include #include int main() { int ofd, nfd, status, len, i = 0; char buf[BUFSIZ]; pid_t* pids; if((ofd = open("sample.txt", O_RDONLY)) == -1) perror(..