2011-04-17 22:26:31 +04:00
|
|
|
#include <syscall.h>
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
/* A Simple Shell */
|
2011-04-18 02:44:29 +04:00
|
|
|
syscall_print("My PID is ");
|
|
|
|
char x[] = {
|
|
|
|
'0' + syscall_getpid(),
|
|
|
|
0
|
|
|
|
};
|
|
|
|
syscall_print(x);
|
|
|
|
syscall_print("\n");
|
2011-04-18 03:54:40 +04:00
|
|
|
int i = syscall_getpid();
|
2011-04-19 00:04:27 +04:00
|
|
|
for (int j = 0; j < 5; ++j) {
|
|
|
|
syscall_fork();
|
|
|
|
if (syscall_getpid() != i) {
|
|
|
|
syscall_print("[Forked]\n");
|
|
|
|
char * bin = "/bin/echo";
|
|
|
|
char * args = "Executed echo.";
|
|
|
|
char * argv_[] = {
|
|
|
|
bin,
|
|
|
|
args,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
syscall_execve(bin, argv_, 0);
|
|
|
|
} else {
|
|
|
|
syscall_print("(hello from parent)\n");
|
|
|
|
}
|
2011-04-18 03:54:40 +04:00
|
|
|
}
|
2011-04-17 22:26:31 +04:00
|
|
|
return 0;
|
|
|
|
}
|