summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2020-06-17 16:37:53 -0600
committerCommit Bot <commit-bot@chromium.org>2020-06-18 23:11:31 +0000
commite387ab4affdd871efdb70ba50dbf24e1bb06888f (patch)
tree3122193d428a37a59f56ae8c9e9000610284fa68
parentf20a27dafac8852d919392f8fba95fb0b220ee48 (diff)
downloadvboot-e387ab4affdd871efdb70ba50dbf24e1bb06888f.tar.gz
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 <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2251039 Reviewed-by: Joel Kitching <kitching@chromium.org>
-rw-r--r--host/lib/subprocess.c16
1 files 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 <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
+#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;