1
/* $Id: environ.c 427 2007-03-08 00:09:47Z steve-beattie $ */
3
/* Copyright (C) 2002-2006 Novell/SUSE
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License as
7
* published by the Free Software Foundation, version 2 of the
20
#define RET_CHLD_SUCCESS 2
21
#define RET_CHLD_FAILURE 3
22
#define RET_CHLD_SIGNAL 4
24
int interp_status(int status)
28
if (WIFEXITED(status)) {
29
if (WEXITSTATUS(status) == 0) {
30
rc = RET_CHLD_SUCCESS;
32
rc = RET_CHLD_FAILURE;
41
int main(int argc, char *argv[])
47
if (argc < 3 || !strchr(argv[2], '=')) {
48
fprintf(stderr, "Usage: %s program VAR=value\n", argv[0]);
52
putenv(strdup(argv[2]));
58
while (wait(&status) != pid);
61
if (!WIFSTOPPED(status)) {
62
retval = interp_status(status);
65
if (retval == RET_CHLD_SUCCESS) {
70
} else if (pid == 0) {
72
retval = execl(argv[1], argv[1], argv[2], (char *) NULL);
76
perror("FAIL: fork() failed:");