1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright (c) 2015, Joyent, Inc. 14 */ 15 16 /* 17 * Alternate execution engine for CTF tools 18 */ 19 20 #include <stdlib.h> 21 #include <string.h> 22 #include <unistd.h> 23 24 #include "ctftools.h" 25 26 void 27 ctf_altexec(const char *env, int argc, char **argv) 28 { 29 const char *alt; 30 char *altexec; 31 32 alt = getenv(env); 33 if (alt == NULL || *alt == '\0') 34 return; 35 36 altexec = strdup(alt); 37 if (altexec == NULL) 38 terminate("failed to allocate memory for altexec\n"); 39 40 if (unsetenv(env) != 0) 41 aborterr("failed to remove %s from environment", env); 42 43 (void) execv(altexec, argv); 44 terminate("failed to altexec %s", altexec); 45 }