Reputation: 1
I am pretty new to both linux and c programming. I need to write a c code that creates two child processes, which is fine, but I need to further change the code of one of the child processes to "the code of a ls-command", and the other to "the code of the ps-command".
This is supposed to be a really simple "pseudo-code", but I am not really sure if I understand the question, any tips?
Upvotes: 0
Views: 494
Reputation: 6709
Sounds like fork() + execve()
traditional combination. Call to fork()
launches a new process which is a copy of the callee. And the consequent call to execve("ls")
will replace the forked process with the content of the ls
executable.
For more information see man 2 fork
and man 3 execv
.
Upvotes: 1