mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-01 12:19:28 +00:00
install: Use posix_spawnp() for starting strip and improve error messages.
This commit is contained in:
parent
5dceed8aeb
commit
236a5a7938
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=262934
@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sha.h>
|
#include <sha.h>
|
||||||
#include <sha256.h>
|
#include <sha256.h>
|
||||||
#include <sha512.h>
|
#include <sha512.h>
|
||||||
|
#include <spawn.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -102,6 +103,8 @@ static enum {
|
|||||||
DIGEST_SHA512,
|
DIGEST_SHA512,
|
||||||
} digesttype = DIGEST_NONE;
|
} digesttype = DIGEST_NONE;
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
static gid_t gid;
|
static gid_t gid;
|
||||||
static uid_t uid;
|
static uid_t uid;
|
||||||
static int dobackup, docompare, dodir, dolink, dopreserve, dostrip, dounpriv,
|
static int dobackup, docompare, dodir, dolink, dopreserve, dostrip, dounpriv,
|
||||||
@ -1215,27 +1218,33 @@ static void
|
|||||||
strip(const char *to_name)
|
strip(const char *to_name)
|
||||||
{
|
{
|
||||||
const char *stripbin;
|
const char *stripbin;
|
||||||
int serrno, status;
|
const char *args[3];
|
||||||
|
pid_t pid;
|
||||||
|
int error, status;
|
||||||
|
|
||||||
switch (fork()) {
|
stripbin = getenv("STRIPBIN");
|
||||||
case -1:
|
if (stripbin == NULL)
|
||||||
serrno = errno;
|
stripbin = "strip";
|
||||||
|
args[0] = stripbin;
|
||||||
|
args[1] = to_name;
|
||||||
|
args[2] = NULL;
|
||||||
|
error = posix_spawnp(&pid, stripbin, NULL, NULL,
|
||||||
|
__DECONST(char **, args), environ);
|
||||||
|
if (error != 0) {
|
||||||
(void)unlink(to_name);
|
(void)unlink(to_name);
|
||||||
errno = serrno;
|
errc(error == EAGAIN || error == EPROCLIM || error == ENOMEM ?
|
||||||
err(EX_TEMPFAIL, "fork");
|
EX_TEMPFAIL : EX_OSERR, error, "spawn %s", stripbin);
|
||||||
case 0:
|
}
|
||||||
stripbin = getenv("STRIPBIN");
|
if (waitpid(pid, &status, 0) == -1) {
|
||||||
if (stripbin == NULL)
|
error = errno;
|
||||||
stripbin = "strip";
|
(void)unlink(to_name);
|
||||||
execlp(stripbin, stripbin, to_name, (char *)NULL);
|
errc(EX_SOFTWARE, error, "wait");
|
||||||
err(EX_OSERR, "exec(%s)", stripbin);
|
/* NOTREACHED */
|
||||||
default:
|
}
|
||||||
if (wait(&status) == -1 || status) {
|
if (status != 0) {
|
||||||
serrno = errno;
|
(void)unlink(to_name);
|
||||||
(void)unlink(to_name);
|
errx(EX_SOFTWARE, "strip command %s failed on %s",
|
||||||
errc(EX_SOFTWARE, serrno, "wait");
|
stripbin, to_name);
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user