Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz dwa programy. Program pierwszy stworzy dwa procesy, a następnie
- program procesu potomnego zastąpi programem drugim.
- */
- // Program 1
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- int main(void)
- {
- pid_t pid;
- pid = fork();
- if(pid == 0){
- if(execl("./05_2", "05_2", (char *)NULL) == -1){
- perror("execl");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
- else if(pid == -1){
- perror("fork");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
- // Program 2
- #include <stdio.h>
- #include <stdlib.h>
- int main(void)
- {
- printf("Program drugi!\n");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement