xref: /netbsd-src/regress/sys/kern/execve/doexec.c (revision b75abedac4cde97d49b0cc16fbe175dca459b84d)
1*b75abedaSsalo /*	$NetBSD: doexec.c,v 1.8 2003/07/26 19:38:48 salo Exp $	*/
2a441b518Scgd 
37e5b2fafScgd /*
47e5b2fafScgd  * Copyright (c) 1993 Christopher G. Demetriou
57e5b2fafScgd  * All rights reserved.
67e5b2fafScgd  *
77e5b2fafScgd  * Redistribution and use in source and binary forms, with or without
87e5b2fafScgd  * modification, are permitted provided that the following conditions
97e5b2fafScgd  * are met:
107e5b2fafScgd  * 1. Redistributions of source code must retain the above copyright
117e5b2fafScgd  *    notice, this list of conditions and the following disclaimer.
127e5b2fafScgd  * 2. Redistributions in binary form must reproduce the above copyright
137e5b2fafScgd  *    notice, this list of conditions and the following disclaimer in the
147e5b2fafScgd  *    documentation and/or other materials provided with the distribution.
157e5b2fafScgd  * 3. All advertising materials mentioning features or use of this software
167e5b2fafScgd  *    must display the following acknowledgement:
17db755e7cScgd  *          This product includes software developed for the
18*b75abedaSsalo  *          NetBSD Project.  See http://www.NetBSD.org/ for
19db755e7cScgd  *          information about NetBSD.
207e5b2fafScgd  * 4. The name of the author may not be used to endorse or promote products
21db755e7cScgd  *    derived from this software without specific prior written permission.
227e5b2fafScgd  *
237e5b2fafScgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
247e5b2fafScgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
257e5b2fafScgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
267e5b2fafScgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
277e5b2fafScgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
287e5b2fafScgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
297e5b2fafScgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
307e5b2fafScgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
317e5b2fafScgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
327e5b2fafScgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33db755e7cScgd  *
34db755e7cScgd  * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
357e5b2fafScgd  */
367e5b2fafScgd 
377e5b2fafScgd #include <errno.h>
387e5b2fafScgd #include <stdio.h>
3963610915Sis #include <stdlib.h>
407e5b2fafScgd #include <string.h>
417e5b2fafScgd #include <unistd.h>
427e5b2fafScgd 
437e5b2fafScgd int
main(argc,argv)447e5b2fafScgd main(argc, argv)
457e5b2fafScgd 	int argc;
467e5b2fafScgd 	char *argv[];
477e5b2fafScgd {
487e5b2fafScgd 	if (argc != 2) {
497e5b2fafScgd 		fprintf(stderr, "usage: %s <progname>\n", argv[0]);
507e5b2fafScgd 		exit(2);
517e5b2fafScgd 	}
527e5b2fafScgd 
5363610915Sis 	unsetenv("LANG");	/* we compare C error strings */
547e5b2fafScgd 	if (execve(argv[1], &argv[1], NULL) == -1) {
557e5b2fafScgd 		printf("%s\n", strerror(errno));
567e5b2fafScgd 		exit(1);
577e5b2fafScgd 	}
587e5b2fafScgd }
59