예제 #1
0
파일: sig.c 프로젝트: AtomSoftTech/retrobsd
void
sig_init()
{
    sigignore(SIGINT);  /* for inquiry of existence via kill call */
#ifdef SIGTTOU
    sigignore(SIGTTOU);
#endif

    sigset(SIGHUP, sig_catcher);
    if (!debugging) {
	sigset(SIGQUIT, sig_catcher);
	sigset(SIGILL, sig_catcher);
	sigset(SIGFPE, sig_catcher);
	sigset(SIGBUS, sig_catcher);
	sigset(SIGSEGV, sig_catcher);
	sigset(SIGSYS, sig_catcher);
	sigset(SIGTERM, sig_catcher);
    }
#ifdef SIGXCPU
    sigset(SIGXCPU, sig_catcher);
#endif
#ifdef SIGCONT
    sigset(SIGCONT, cont_catcher);
#endif
#ifdef SIGTSTP
    sigset(SIGTSTP, stop_catcher);
    sigset(SIGSTOP, stop_catcher);
#endif
}
예제 #2
0
/* The main function of this shell
*/
int
main(int argc, char** argv, char** envp)
{
    sigignore(SIGTSTP);
    sigignore(SIGTERM);
    if (argc > 2) {
        printf("Shell: too many arguments!\n");
        return -1;
    } else if (argc == 2) {
        alarm_time = atoi(argv[1]);
        alarm_enabled = 1;
    }
    shell_init();
    int status = 0;
    env = envp;
    while (1) {
        status = respond_cycle();
        if (status == EXIT_SHELL)
            break;
        prepare_for_next_cycle();
        history_add(cmd_char);
    }
    //before_exit(status);
    fflush(stdout);
    return 0;
}
예제 #3
0
/*ARGSUSED*/
void
leave(int status)
{
	(void) sigignore(SIGPIPE);
	(void) sigignore(SIGALRM);
	/* clear(); */
	(void) move(LINES, 0);
	(void) refresh();
	if (logfd > -1) wrefresh_file(stdscr, logfd);
	quit(0);
}
예제 #4
0
TEST(signal, sigignore) {
  errno = 0;
  EXPECT_EQ(-1, sigignore(SIGKILL));
  EXPECT_EQ(errno, EINVAL);

  errno = 0;
  EXPECT_EQ(-1, sigignore(SIGSTOP));
  EXPECT_EQ(errno, EINVAL);

  ScopedSignalHandler sigalrm{SIGALRM};
  ASSERT_EQ(0, sigignore(SIGALRM));

  struct sigaction sa;
  ASSERT_EQ(0, sigaction(SIGALRM, nullptr, &sa));
  EXPECT_EQ(SIG_IGN, sa.sa_handler);
}
예제 #5
0
파일: http_bypass.c 프로젝트: tanec/fcache
int
main(int argc, char **argv)
{
  // initialize libraries
  struct evhttp *httpd;

  if (sigignore(SIGPIPE) == -1) {
    perror("failed to ignore SIGPIPE; sigaction");
    exit(EXIT_FAILURE);
  }

  host = argv[2];
  port = atoi(argv[3]);
  event_init();
  httpd = evhttp_start("0.0.0.0", atoi(argv[1]));
  if (httpd == NULL) {
    perror("evhttpd failed!");
    exit(1);
  }

  /* Set a callback for all other requests. */
  evhttp_set_gencb(httpd, proxycb, NULL);

  event_dispatch();
  /* Not reached in this code as it is now. */
  evhttp_free(httpd);

  return EXIT_SUCCESS;
}
예제 #6
0
/*
 * intrInitMD() -- Target-specific initialization.
 */
extern void
intrInitMD()
{
    memset(pending_signals, 0, sizeof(pending_signals));
    sigignore(SIGPIPE);
    sigMonitorInit();
}
예제 #7
0
파일: 1-1.c 프로젝트: Mellanox/arc_ltp
int main()
{
	struct sigaction act;

	act.sa_handler = handler;
	act.sa_flags = 0;
	sigemptyset(&act.sa_mask);
	if (sigaction(SIGABRT,  &act, 0) == -1) {
		perror("Unexpected error while attempting to setup test "
		       "pre-conditions");
		return PTS_UNRESOLVED;
	}

	sigignore(SIGABRT);

	if (raise(SIGABRT) == -1) {
		perror("Unexpected error while attempting to setup test "
		       "pre-conditions");
		return PTS_UNRESOLVED;
	}

	if (handler_called) {
		printf("FAIL: Signal was not ignored\n");
		return PTS_FAIL;
	}
	printf("PASS\n");
	return PTS_PASS;
}
예제 #8
0
파일: neoagent.c 프로젝트: marktan/neoagent
static void na_setup_signals (void)
{
    struct sigaction sig_exit_handler;
    struct sigaction sig_clear_handler;
    struct sigaction sig_reconf_handler;

    sigemptyset(&sig_exit_handler.sa_mask);
    sigemptyset(&sig_clear_handler.sa_mask);
    sigemptyset(&sig_reconf_handler.sa_mask);
    sig_exit_handler.sa_handler   = na_signal_exit_handler;
    sig_clear_handler.sa_handler  = na_signal_clear_handler;
    sig_reconf_handler.sa_handler = na_signal_reconf_handler;
    sig_exit_handler.sa_flags     = 0;
    sig_clear_handler.sa_flags    = 0;
    sig_reconf_handler.sa_flags   = 0;

    if (sigaction(SIGTERM, &sig_exit_handler,   NULL) == -1 ||
        sigaction(SIGINT,  &sig_exit_handler,   NULL) == -1 ||
        sigaction(SIGALRM, &sig_exit_handler,   NULL) == -1 ||
        sigaction(SIGHUP,  &sig_exit_handler,   NULL) == -1 ||
        sigaction(SIGUSR1, &sig_clear_handler,  NULL) == -1 ||
        sigaction(SIGUSR2, &sig_reconf_handler, NULL) == -1)
    {
        NA_DIE_WITH_ERROR(NA_ERROR_FAILED_SETUP_SIGNAL);
    }

    if (sigignore(SIGPIPE) == -1) {
        NA_DIE_WITH_ERROR(NA_ERROR_FAILED_IGNORE_SIGNAL);
    }

    SigExit   = 0;
    SigClear  = 0;
    SigReconf = 0;

}
예제 #9
0
int main(int argc, char **argv)
{
    sigignore(SIGPIPE);
    if (argc > 1) 
        if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
            printf("\n    Usage: %s [ThreadCount]\n", argv[0]);
            printf("\n    Default: %s 4\n", argv[0]);
            exit(1);
        }

    if (argc > 1)
        thread_count = atoi(argv[1]);

    rlimit of = {1000000, 1000000};
    if (-1 == setrlimit(RLIMIT_NOFILE, &of)) {
        perror("setrlimit");
        exit(1);
    }

    go server;

    boost::thread_group tg;
    for (int i = 0; i < thread_count; ++i)
        tg.create_thread([] { g_Scheduler.RunUntilNoTask(); });
    //tg.join_all();
    for (;;)
    {
        sleep(1);
        show_status();
    }
    return 0;
}
예제 #10
0
파일: main.c 프로젝트: forhappy/intercept
static int  
set_details()
{
    int  n;
#if (TC_ADVANCED)
    int  len;
#endif

    for (n = tc_pagesize; n >>= 1; tc_pagesize_shift++) { /* void */ }

#if (!TC_ADVANCED)
    /* retrieve ip address */
    if (srv_settings.raw_ip_list != NULL) {
        tc_log_info(LOG_NOTICE, 0, "-x para:%s", srv_settings.raw_ip_list);
        retrieve_ip_addr();
    }
#else 
    if (srv_settings.raw_device != NULL) {
        tc_log_info(LOG_NOTICE, 0, "device:%s", srv_settings.raw_device);
        if (strcmp(srv_settings.raw_device, DEFAULT_DEVICE) == 0) {
            srv_settings.raw_device = NULL; 
        } else {
            retrieve_devices(srv_settings.raw_device, &(srv_settings.devices));
        }
    }

    if (srv_settings.user_filter != NULL) {
        tc_log_info(LOG_NOTICE, 0, "user filter:%s", srv_settings.user_filter);
        len = strlen(srv_settings.user_filter);
        if (len >= MAX_FILTER_LENGH) {
            tc_log_info(LOG_ERR, 0, "user filter is too long");
            return -1;
        }
        memcpy(srv_settings.filter, srv_settings.user_filter, len);
    } else {
        fprintf(stderr, "please set filter (-F param) for capturing packets\n");
        tc_log_info(LOG_ERR, 0, "not set filter (-F param)");
        return -1;
    }
#endif

#if (TC_NFQUEUE)
    if (srv_settings.max_queue_len <= 1024) {
        srv_settings.max_queue_len = -1;
    }
#endif

    /* daemonize */
    if (srv_settings.do_daemonize) {
        if (sigignore(SIGHUP) == -1) {
            tc_log_info(LOG_ERR, errno, "failed to ignore SIGHUP");
        }
        if (daemonize() == -1) {
            fprintf(stderr, "failed to daemonize() in order to daemonize\n");
            return -1;
        }
    }

    return 0;
}
예제 #11
0
//ignore
void Signals::Ignore(int signal)
{
#ifndef _WINDOWS
#ifndef MIPS
	sigignore(signal);
	LOG_INFO_APP("[Signal] signal=" << signal << " will be ignored!!!");
#endif
#endif
}
예제 #12
0
int main()
{

	if (sigignore(SIGABRT) != 0) {
		perror("sigignore failed -- returned -- test aborted");
		return PTS_UNRESOLVED;
	} 
	printf("sigignore passed\n");
	return PTS_PASS;
}
예제 #13
0
void
breaker (void)
{
#   ifdef need_breaker
    int kill (pid_t x, int sig);/* with ansi flags set, prototype explicitly */
    int sigignore( int sig);
    sigignore (SIGTRAP);
    kill (getpid(), SIGTRAP);
#   endif /* need_breaker */
}
예제 #14
0
/*
 * robot_makeChild - Ensure the child process exists.
 */
static void robot_makeChild() {
    int     pipes[2] = { -1, -1 };

    /*
     * First check if child exists.
     */
    if (child != -1) {
        /*
         * Sending signal-0 only does error checking.
         * If it returns -1 the child does not exist.
         */
        if (kill(child, 0) != -1) {
            return;
        }
    }

    /*
     * It does not exist.    Set up the pipe, fork, etc.
     */
#ifdef __linux__
    socketpair(AF_UNIX, SOCK_STREAM, 0, pipes);
#else
    pipe(pipes);
#endif
    pipeToChild = pipes[0];

#ifdef __linux__
    child = fork();     /* fork1() only re-creates the one thread */
#else
    child = fork1();     /* fork1() only re-creates the one thread
		            * That's all we need.
		            */
#endif
    /* The child goes off to handle cmds.
     * Nothing for the parent to do but continue
     * about its own business.
     */
    if (child == 0) {
        /* in child */
	int pipeToParent;
	char arg1[MAX_DIGITS+1];
	char * arg2;

	pipeToParent = dup(pipes[1]);
	sprintf(arg1, "%d", pipeToParent);
	arg2 = DisplayString(awt_display);
	execl(RobotChildExePath, ROBOT_ARG0, arg1, arg2, NULL);
	perror("Couldn't execl robot child process");
    } else {
        /* in parent */
        /* SIGPIPE would make us crash.    So we ignore it */
        sigignore(SIGPIPE);
        robot_setupPipe(pipeToChild);
    }
}
예제 #15
0
파일: 1-2.c 프로젝트: SummerSnail2014/haiku
int main()
{
	int child_pid, child_pgid;

	if ((child_pid = fork()) == 0) {
		/* child here */
		struct sigaction act;
		act.sa_handler=myhandler;
		act.sa_flags=0;
		sigemptyset(&act.sa_mask);
		sigaction(SIGTOTEST, &act, 0);

		/* change child's process group id */
		setpgrp();

		sigpause(SIGABRT);

		return 0;
	} else {
		/* parent here */
		int i;
		sigignore(SIGTOTEST);

		sleep(1);
		if ((child_pgid = getpgid(child_pid)) == -1) {
			printf("Could not get pgid of child\n");
			return PTS_UNRESOLVED;
		}


		if (killpg(child_pgid, SIGTOTEST) != 0) {
			printf("Could not raise signal being tested\n");
			return PTS_UNRESOLVED;
		}

		if (wait(&i) == -1) {
			perror("Error waiting for child to exit\n");
			return PTS_UNRESOLVED;
		}

		if (WEXITSTATUS(i)) {
			printf("Child exited normally\n");
			printf("Test PASSED\n");
			return PTS_PASS;
		} else {
			printf("Child did not exit normally.\n");
			printf("Test FAILED\n");
			return PTS_FAIL;
		}
	}

	printf("Should have exited from parent\n");
	printf("Test FAILED\n");
	return PTS_FAIL;
}
예제 #16
0
int writepipe(int fd, char *buff, int n)
{
int k;

   sigignore(SIGPIPE);
   k = write(fd, buff, n);
   if (k <0 && errno == EPIPE) 
    	return 0;
   else 
       return k;
}
예제 #17
0
/**
 * @author Petr Djakow
 */
void Utils::signalIgnore(const int signum)
{
	#ifdef _GNU_SOURCE
		if(sigignore(signum) == -1)
			FATAL_ERROR(("sigignore(%d)", signum));
		OUT_DEBUG(("Signal '%s' will be ignored", strsignal(signum)));
	#else
		set_signal_handler(signum, SIG_IGN);
		OUT_DEBUG(("Signal '%d' will be ignored", signum));
	#endif
}
예제 #18
0
int main(int argc, char** argv)
{
    pid_t pid;
    int pipeline[2];
    char pipeReadBuffer[GCC_OUTPUT_BUFFER_SIZE] = {0};   
    
    
    // Traitement des taches du parent
    execute_folder_operations(get_folder_path(argc, argv));
    cFilesList = get_c_files(cFilesList);
    check_folder_has_cFiles(cFilesList);
    create_pipeline(pipeline);
    pid = create_child();
    
    
    if (pid > 0) { // PARENT - Ajustements propre a ce processus
        free_array_of_array(cFilesList);        // Free, cFilesList maintenant inutile pour ce processus
        signal(SIGINT, set_run_status);         // Gestion de la fin du prog par le processus parent
        
        while (RUN) {                           // Lance la lecture sur pipe avec enfant
            read(pipeline[0], pipeReadBuffer, sizeof(pipeReadBuffer));
            
            if (strlen(pipeReadBuffer) != 0)
                //printf("DEBUG-> Parent received:\n%s", pipeReadBuffer);
                printf("%s", pipeReadBuffer);
                
            strcpy(pipeReadBuffer, "");         // Vide buffer
        }
        
        kill(pid, SIGUSR1);                     // Kill Child Process
        wait(NULL);
        
    } else {       // ENFANT - Lance les operations de traitements
        sigignore(SIGINT);                      // Le parent s'occupe de tuer l'enfant        
        signal(SIGUSR1, child_clean_atexit);    // Ecoute directive de terminaison envoyee par le parent
        initMutex();                            // Initialisation du ou des mutex(es)
        
        while (1) {
            JobsList = update_JobsList(JobsList, cFilesList); // Ajout d'une "job" pour tous les nouveaux fichiers

            if (JobsList != NULL)
                update_threads(JobsList, pipeline); // Creation d'un thread pour les nouvelles "Jobs" dans le tableau
            
            sleep(FOLDER_POLLING_DELAY);            // Inutile de verifier le dossier trop rapidement...
            
            cFilesList = free_array_of_array(cFilesList); // Nettoyage
            cFilesList = get_c_files(cFilesList);   // Update la liste et boucle...
        }
    }
    
    return (EXIT_SUCCESS);
}
예제 #19
0
void
final_init()
{
#ifdef SIGTSTP
    sigset(SIGTSTP, stop_catcher);	/* job control signals */
    sigset(SIGTTOU, stop_catcher);	/* job control signals */
    sigset(SIGTTIN, stop_catcher);	/* job control signals */
#endif

    sigset(SIGINT, int_catcher);	/* always catch interrupts */
#ifdef SIGHUP
    sigset(SIGHUP, sig_catcher);	/* and hangups */
#endif
#ifdef SIGWINCH
    sigset(SIGWINCH, winch_catcher);
#endif
#ifdef SUPPORT_NNTP
    sigset(SIGPIPE,pipe_catcher);
#endif

#ifndef lint
#ifdef SIGEMT
    sigignore(SIGEMT);		/* Ignore EMT signals from old [t]rn's */
#endif
#endif

#ifdef DEBUG
    /* sometimes we WANT a core dump */
    if (debug & DEB_COREDUMPSOK)
	return;
#endif
    sigset(SIGILL, sig_catcher);
#ifdef SIGTRAP
    sigset(SIGTRAP, sig_catcher);
#endif
    sigset(SIGFPE, sig_catcher);
#ifdef SIGBUS
    sigset(SIGBUS, sig_catcher);
#endif
    sigset(SIGSEGV, sig_catcher);
#ifdef SIGSYS
    sigset(SIGSYS, sig_catcher);
#endif
    sigset(SIGTERM, sig_catcher);
#ifdef SIGXCPU
    sigset(SIGXCPU, sig_catcher);
#endif
#ifdef SIGXFSZ
    sigset(SIGXFSZ, sig_catcher);
#endif
}
예제 #20
0
static void
sigsetmask(uint_t omask)
{
	int i;

	for (i = 0; i < 32; i++)
		if (omask & (1 << i)) {
			if (sigignore(1 << i) == (int)SIG_ERR) {
				(void) fprintf(stderr,
				    "Bad signal 0x%x\n", (1 << i));
				exit(31+1);
			}
		}
}
예제 #21
0
파일: main.c 프로젝트: edwardlau/tcpcopy
static int  
set_details()
{
    /* ignore SIGPIPE signals */
    if (sigignore(SIGPIPE) == -1) {
        perror("failed to ignore SIGPIPE; sigaction");
        return -1;
    }

    /* retrieve ip address */
    if (srv_settings.raw_ip_list != NULL) {
        tc_log_info(LOG_NOTICE, 0, "-x parameter:%s", 
                srv_settings.raw_ip_list);
        retrieve_ip_addr();
    }

    if (srv_settings.timeout == 0) {
        srv_settings.timeout = DEFAULT_TIMEOUT;
    }
    /* daemonize */
    if (srv_settings.do_daemonize) {
        if (sigignore(SIGHUP) == -1) {
            tc_log_info(LOG_ERR, errno, "Failed to ignore SIGHUP");
        }
        if (daemonize() == -1) {
            fprintf(stderr, "failed to daemon() in order to daemonize\n");
            return -1;
        }
    }

    if (tc_time_set_timer(1000) == TC_ERROR) {
        tc_log_info(LOG_ERR, 0, "set timer error");
        return -1;
    }   

    return 0;
}
예제 #22
0
파일: 6-2.c 프로젝트: 1587/ltp
int main(void)
{
	if (sigignore(SIGSTOP) == -1) {
		if (EINVAL == errno) {
			printf("Test PASSED: errno set to EINVAL\n");
			return PTS_PASS;
		} else {
			printf("errno was not set to EINVAL\n");
			return PTS_FAIL;
		}
	}

	printf("sigignore did not return -1\n");
	return PTS_FAIL;
}
예제 #23
0
파일: 6-2.c 프로젝트: mmanley/Antares
int main()
{
    if (sigignore(SIGSTOP) == -1) {
        if (EINVAL == errno) {
            printf("%ssigignore_6-2:%s              %sPASSED%s\n", boldOn, boldOff, green, normal);
            return PTS_PASS;
        } else {
            printf ("errno not set to EINVAL\n");
            return PTS_FAIL;
        }
    }

    printf("sigignore did not return -1\n");
    return PTS_FAIL;
}
예제 #24
0
int main(int argc, char const *argv[])
{
	int i;
	pid_t n1;
	n1 = fork();

	if (n1 == 0) {	
		printf("Sorry Tallahassee, no zombie for you this time..\n");	
	}
	else{
		sigignore(SIGCHLD);
		sleep(2);		
		getchar();
	}	
	return 0;
}
예제 #25
0
파일: fwd.c 프로젝트: pzbitskiy/fssh
int main(int argc, char **argv)
{
	int rc = 1;

	if (argc < 3) {
		fprintf(stderr, "Usage: %s ZEROMQ_ENDPOINT PGM [ARGS]...\n", argv[0]);
		goto _out;
	}

	pid_t pid = fork();
	if (pid == -1) {
		TRACE_ERRNO("fork() failed");
		goto _out;
	}

	if (pid == 0)
		execute(argc - 1, argv + 1);

	if (sigignore(SIGCHLD) == -1) {
		TRACE_ERRNO("sigignore() failed");
		goto _out;
	}

	sigset_t all;
	if (sigfillset(&all) == -1) {
		TRACE_ERRNO("sigfillset() failed");
		goto _out;
	}
	if (sigdelset(&all, SIGINT)) {
		TRACE_ERRNO("sigdelset() failed");
		goto _out;
	}
	if (sigdelset(&all, SIGTERM)) {
		TRACE_ERRNO("sigdelset() failed");
		goto _out;
	}
	if (sigsuspend(&all) == -1 && errno != EINTR) {
		TRACE_ERRNO("sigsuspend() failed");
		goto _out;
	}

	rc = 0;

_out:
	return rc;
}
예제 #26
0
파일: 5-core.c 프로젝트: Nan619/ltp-ddt
int main(int argc, char *argv[])
{
    int signo;

    if (argc < 2) {
        printf("Usage:  %s [1|2|3|4]\n", argv[0]);
        return PTS_UNRESOLVED;
    }

    /*
       Various error conditions
     */
    switch (argv[1][0]) {
    case '1':
        signo = -1;
        break;
    case '2':
        signo = -10000;
        break;
    case '3':
        signo = INT32_MIN + 1;
        break;
    case '4':
        signo = INT32_MIN;
        break;
    default:
        printf("Usage:  %s [1|2|3|4]\n", argv[0]);
        return PTS_UNRESOLVED;
    }

    if (sigignore(signo) == -1) {
        if (EINVAL == errno) {
            printf("errno set to EINVAL\n");
            return PTS_PASS;
        } else {
            printf("errno not set to EINVAL\n");
            return PTS_FAIL;
        }
    }

    printf("sighold did not return -1\n");
    return PTS_FAIL;
}
예제 #27
0
static uint_t
sigblock(uint_t omask)
{
	uint_t previous = 0;
	uint_t temp;
	int i;

	for (i = 0; i < 32; i++)
		if (omask & (1 << i)) {
			if ((temp = sigignore(1 << i)) == (int)SIG_ERR) {
				(void) fprintf(stderr,
				    "Bad signal 0x%x\n", (1 << i));
				exit(31+1);
			}
			if (i == 0)
				previous = temp;
		}

	return (previous);
}
예제 #28
0
void SimpleThread::sleep(int32_t millis)
{
#if U_PLATFORM == U_PF_SOLARIS
    sigignore(SIGALRM);
#endif

#ifdef HPUX_CMA
    cma_sleep(millis/100);
#elif U_PLATFORM == U_PF_HPUX || U_PLATFORM == U_PF_OS390
    millis *= 1000;
    while(millis >= 1000000) {
        usleep(999999);
        millis -= 1000000;
    }
    if(millis > 0) {
        usleep(millis);
    }
#else
    usleep(millis * 1000);
#endif
}
예제 #29
0
//to clear signal mask and set the handler to default
static int setsigenv()
	{
	int Signum, ret, ret1 = KErrGeneral ;
	for(Signum=1; Signum <= 64; Signum++)
		{
		if ((Signum == SIGKILL) || (Signum == SIGSTOP))
			{
			continue;
			}
		ret = sigignore(Signum);
		if (ret != 0)
			{
			goto close;
			}
		ret = sigrelse(Signum);
		if (ret != 0)
			{
			goto close;
			}
		}
	User::After(50000);
	for(Signum=1; Signum <= 64; Signum++)
		{
		if ((Signum == SIGKILL) || (Signum == SIGSTOP))
			{
			continue;
			}		
		if (signal(Signum,SIG_DFL) == SIG_ERR)
			{
			goto close;
			}	
		}
	ret1 = KErrNone;
	
	close:
	alarm(0);
	return ret1;
	}
예제 #30
0
static void *
tf (void *arg)
{
    /* Ignore SIGUSR1 and block SIGUSR2.  */
    if (sigignore (SIGUSR1) != 0)
    {
        puts ("sigignore failed");
        exit (1);
    }

    sigset_t ss;
    sigemptyset (&ss);
    sigaddset (&ss, SIGUSR2);
    if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
    {
        puts ("1st run: sigmask failed");
        exit (1);
    }

    char **oldargv = (char **) arg;
    size_t n = 1;
    while (oldargv[n] != NULL)
        ++n;

    char **argv = (char **) alloca ((n + 1) * sizeof (char *));
    for (n = 0; oldargv[n + 1] != NULL; ++n)
        argv[n] = oldargv[n + 1];
    argv[n++] = (char *) "--direct";
    argv[n] = NULL;

    execv (argv[0], argv);

    puts ("execv failed");

    exit (1);
}