Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* run-program-dots.c */
- #include <sys/wait.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <signal.h>
- int child_proc;
- void sigchild_handler(int signum)
- {
- exit(0);
- }
- int main( int argc, char *argv[], char *envp[] )
- {
- if( argc < 2 ) {
- printf( "Insufficient arguments.\n" );
- return -1;
- }
- struct sigaction act;
- act.sa_handler = sigchild_handler;
- child_proc = fork();
- if(child_proc == 0) {
- execve(argv[1] , argv + 1 ,NULL);
- } else {
- sigaction(SIGCHLD, &act, NULL);
- while(1) {
- sleep(1);
- printf(".");
- fflush(stdout);
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment