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>
diff --git a/host/lib/subprocess.c b/host/lib/subprocess.c
index be53583..242b189 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 @@
 		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;