From e387ab4affdd871efdb70ba50dbf24e1bb06888f Mon Sep 17 00:00:00 2001 From: Jack Rosenthal Date: Wed, 17 Jun 2020 16:37:53 -0600 Subject: host/lib/subprocess: replace constructor function & perror with VB2_DEBUG Currently this had perror to print the error message, but we can get rid of this and the constructor function reasonably if we switch to VB2_DEBUG. This was changed since the Loonix team cannot rely on glibc-specific behaviors, and passing argv to constructor functions is glibc-specific. See the notes on cl/316913250 for a little bit of background. BUG=none BRANCH=none TEST=unit tests Change-Id: I5de76306d5a8615fdc3afcfb772a2eb32557aa87 Signed-off-by: Jack Rosenthal Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2251039 Reviewed-by: Joel Kitching --- host/lib/subprocess.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/host/lib/subprocess.c b/host/lib/subprocess.c index be535838..242b1897 100644 --- a/host/lib/subprocess.c +++ b/host/lib/subprocess.c @@ -3,25 +3,18 @@ * found in the LICENSE file. */ +#include #include #include #include #include #include +#include "2common.h" #include "subprocess.h" #define MAX_CB_BUF_SIZE 2048 -static char *program_name; - -__attribute__((constructor, used)) -static int libinit(int argc, char **argv) -{ - program_name = *argv; - return 0; -} - static int init_target_private(struct subprocess_target *target) { switch (target->type) { @@ -325,10 +318,7 @@ int subprocess_run(const char *const argv[], return WEXITSTATUS(status); fail: - if (program_name) - perror(program_name); - else - perror("subprocess"); + VB2_DEBUG("Failed to execute external command: %s\n", strerror(errno)); if (pid == 0) exit(127); return -1; -- cgit v1.2.1