Files
haiku-beta6/src/kernel/apps/exec_test.c
T
Philippe Houdoin ce0c82200a Fixed the "no previous prototype" warning.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10962 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-01-22 21:23:33 +00:00

53 lines
1010 B
C

/*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
#include <OS.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
static void
print_process_info(const char *text)
{
puts(text);
printf("\tsession_id = %ld\n", getsid(0));
printf("\tgroup_id = %ld\n", getpgid(0));
printf("\tprocess_id = %ld\n", getpid());
printf("\tparent_id = %ld\n", getppid());
}
int
main(int argc, char **argv)
{
printf("exec_test: this is thread %ld\n", find_thread(NULL));
if (argc < 2) {
print_process_info("before exec():");
puts("going to execl()...");
execl("/bin/exec_test", "/bin/exec_test", "argument 1", NULL);
printf("execl() returned: %s\n", strerror(errno));
} else {
int i;
print_process_info("after exec():");
puts("got arguments:");
for (i = 0; i < argc; i++)
printf("%d: \"%s\"\n", i, argv[i]);
setsid();
print_process_info("after setsid():");
}
return 0;
}