diff options
[SP/P04] Solved exercises
1 files changed, 12 insertions, 0 deletions
| -rw-r--r-- | Year 3/System programming/Practice04/ex1.c | 12 |
diff --git a/Year 3/System programming/Practice04/ex1.c b/Year 3/System programming/Practice04/ex1.c new file mode 100644 index 0000000..da92ec6 --- /dev/null +++ b/Year 3/System programming/Practice04/ex1.c @@ -0,0 +1,12 @@ +#include <stdio.h> // printf, perror +#include <unistd.h> // getpid, getppid, execlp +#include <sys/types.h> // pid_t +int main(int argc, char* argv[]) { + pid_t pid = getpid(); + pid_t parent = getppid(); + printf("%d %d\n", pid, parent); + if (execlp("ps", "ps", (char*)NULL) < 0) { + perror("execlp"); + return 1; + } +} |
