aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/libc_exec.go
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-06-21 14:51:33 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-06-21 14:51:33 +0000
commit1430da15e99541183a2d740f7cc6b8b3c42e8cf2 (patch)
tree73936aba47fe1dc71e9cc05af9747036e935608c /compiler_wrapper/libc_exec.go
parentb75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff)
parent4e4201457e5f51a132101c611c79ccff9f713c8b (diff)
downloadtoolchain-utils-1430da15e99541183a2d740f7cc6b8b3c42e8cf2.tar.gz
Change-Id: I42e654e28c12d7f20bdac244d1fca60a3d6aa862
Diffstat (limited to 'compiler_wrapper/libc_exec.go')
-rw-r--r--compiler_wrapper/libc_exec.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/compiler_wrapper/libc_exec.go b/compiler_wrapper/libc_exec.go
index f8db9d86..d9867733 100644
--- a/compiler_wrapper/libc_exec.go
+++ b/compiler_wrapper/libc_exec.go
@@ -7,15 +7,31 @@
package main
// #include <errno.h>
+// #include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// #include <unistd.h>
+// #include <sys/types.h>
+// #include <sys/wait.h>
//
// int libc_exec(const char *pathname, char *const argv[], char *const envp[]) {
-// if (execve(pathname, argv, envp) != 0) {
+// // Since fork() brings us to one thread, we can only use async-signal-safe funcs below.
+// pid_t pid = fork();
+// if (pid == 0) {
+// execve(pathname, argv, envp);
+// fprintf(stderr, "exec failed (errno: %d)\n", errno);
+// _exit(1);
+// }
+// if (pid < 0) {
+// return errno;
+// }
+//
+// int wstatus;
+// pid_t waited = waitpid(pid, &wstatus, 0);
+// if (waited == -1) {
// return errno;
// }
-// return 0;
+// exit(WEXITSTATUS(wstatus));
//}
import "C"
import (
@@ -29,7 +45,7 @@ import (
// Note that this changes the go binary to be a dynamically linked one.
// See crbug.com/1000863 for details.
// To use this version of exec, please add '-tags libc_exec' when building Go binary.
-// Without the tags, libc_exec.go will be used.
+// Without the tags, libc_exec.go will not be used.
func execCmd(env env, cmd *command) error {
freeList := []unsafe.Pointer{}