execve_helper.c revision 159097
1227652Sgrehan/* $NetBSD: doexec.c,v 1.8 2003/07/26 19:38:48 salo Exp $ */ 2227652Sgrehan 3227652Sgrehan/* 4227652Sgrehan * Copyright (c) 1993 Christopher G. Demetriou 5227652Sgrehan * All rights reserved. 6227652Sgrehan * 7227652Sgrehan * Redistribution and use in source and binary forms, with or without 8227652Sgrehan * modification, are permitted provided that the following conditions 9227652Sgrehan * are met: 10227652Sgrehan * 1. Redistributions of source code must retain the above copyright 11227652Sgrehan * notice, this list of conditions and the following disclaimer. 12227652Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 13227652Sgrehan * notice, this list of conditions and the following disclaimer in the 14227652Sgrehan * documentation and/or other materials provided with the distribution. 15227652Sgrehan * 3. All advertising materials mentioning features or use of this software 16227652Sgrehan * must display the following acknowledgement: 17227652Sgrehan * This product includes software developed for the 18227652Sgrehan * NetBSD Project. See http://www.NetBSD.org/ for 19227652Sgrehan * information about NetBSD. 20227652Sgrehan * 4. The name of the author may not be used to endorse or promote products 21227652Sgrehan * derived from this software without specific prior written permission. 22227652Sgrehan * 23227652Sgrehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24227652Sgrehan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25227652Sgrehan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26227652Sgrehan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27230450Sbrueffer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28227652Sgrehan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29227652Sgrehan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30227652Sgrehan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31227652Sgrehan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32227652Sgrehan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33227652Sgrehan * 34227652Sgrehan * $FreeBSD: head/tools/regression/execve/doexec.c 159097 2006-05-31 11:13:10Z maxim $ 35227652Sgrehan */ 36227652Sgrehan 37227652Sgrehan#include <errno.h> 38265417Sbryanv#include <stdio.h> 39227652Sgrehan#include <stdlib.h> 40227652Sgrehan#include <string.h> 41227652Sgrehan#include <unistd.h> 42227652Sgrehan 43227652Sgrehanint 44227652Sgrehanmain(argc, argv) 45227652Sgrehan int argc; 46227652Sgrehan char *argv[]; 47227652Sgrehan{ 48227652Sgrehan if (argc != 2) { 49227652Sgrehan fprintf(stderr, "usage: %s <progname>\n", argv[0]); 50227652Sgrehan exit(2); 51227652Sgrehan } 52227652Sgrehan 53227652Sgrehan unsetenv("LANG"); /* we compare C error strings */ 54227652Sgrehan if (execve(argv[1], &argv[1], NULL) == -1) { 55227652Sgrehan printf("%s\n", strerror(errno)); 56227652Sgrehan exit(1); 57227652Sgrehan } 58227652Sgrehan} 59227652Sgrehan