Check that putenv succeeded, suggested by Jonas Holmberg.

This commit is contained in:
Matt Kraai 2001-05-11 15:16:28 +00:00
parent c96381be40
commit eb5f433736
2 changed files with 4 additions and 2 deletions

View File

@ -59,7 +59,8 @@ extern int env_main(int argc, char** argv)
cleanenv[0] = NULL;
}
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
putenv(*argv);
if (putenv(*argv) < 0)
perror_msg_and_die("%s", *argv);
if (*argv) {
execvp(*argv, argv);
perror_msg_and_die("%s", *argv);

3
env.c
View File

@ -59,7 +59,8 @@ extern int env_main(int argc, char** argv)
cleanenv[0] = NULL;
}
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
putenv(*argv);
if (putenv(*argv) < 0)
perror_msg_and_die("%s", *argv);
if (*argv) {
execvp(*argv, argv);
perror_msg_and_die("%s", *argv);