Hi,
i'm create custom /sbin/init program.
to execute file use function:
after start zombie test program:
sleep die and leave zombie
what need do with execbin()?
---
sorry for my bad english :r
i'm create custom /sbin/init program.
to execute file use function:
Code:
void sigCHLD(int i UNUSED)
{
pid_t pid = getpid();
while(waitpid(pid, NULL, 0) > 0)
continue;
}
int execbin(char *argv[])
{
if(!argv[0])
return 1;
pid_t pid = fork();
if(pid == 0)
{
struct sigaction sa;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = sigCHLD;
sigaction(SIGCHLD, &sa, NULL);
execve(argv[0], argv, NULL);
exit(0);
}
if(pid == -1)
{
printf("execbin(%s): fork error\n", argv[0]);
return 1;
}
while(waitpid(pid, NULL, 0) > 0)
continue;
return 0;
}
after start zombie test program:
Code:
int main(int argc, char *argv[])
{
printf("Start\n");
pid_t pid;
if((pid = fork()) > 0)
waitpid(pid, NULL, 0);
else
{
if(fork() > 0)
exit(0);
else
{
char *ar[] = {"/bin/sleep", "5", NULL};
execve(ar[0], ar, NULL);
exit(0);
}
exit(0);
}
printf("Finish\n");
return 0;
}
what need do with execbin()?
---
sorry for my bad english :r