V C-ju napišite program, ki vsakih 5 sekund izpiše vse procese, ki tečejo na sistemu.
CODE:
-
V C-ju napišite program, ki vsakih 5 sekund izpiše vse procese, ki tečejo na sistemu. V programu ne smete uporabljati funkcij system(...) in popen(...).
C:
-
#include <stdio .h>
-
#include <unistd .h>
-
#include <sys /types.h>
-
-
int main(int argc, char *argv[])
-
{
-
int pid;
-
while (1==1)
-
{
-
-
pid = fork();
-
if (pid == -1)
-
{
-
}
-
if (pid == 0)
-
{
-
execlp("ps", argv[0], "-e", 0);
-
-
}
-
else{
-
waitpid (pid, NULL, 0);
-
}
-
-
sleep(5);
-
-
}
-
return 0;
-
}