提交 776e2a59 编写于 作者: D Derek Parker

Null terminate argv array in Go land not C land

上级 c1e7f8c4
......@@ -12,8 +12,6 @@ fork_exec(char *argv0, char **argv, int size,
int fd[2];
if (pipe(fd) < 0) return -1;
argv[size-1] = '\0';
kern_return_t kret;
pid_t pid = fork();
if (pid > 0) {
......
......@@ -50,16 +50,19 @@ func Launch(cmd []string) (*Process, error) {
}
argv0 := C.CString(argv0Go)
argvSlice := make([]*C.char, 0, len(cmd)+1)
for _, arg := range cmd {
argvSlice = append(argvSlice, C.CString(arg))
}
// argv array must be null terminated.
argvSlice = append(argvSlice, nil)
dbp := New(0)
var pid int
dbp.execPtraceFunc(func() {
ret := C.fork_exec(argv0, &argvSlice[0], C.int(len(argvSlice)), &dbp.os.task, &dbp.os.portSet, &dbp.os.exceptionPort, &dbp.os.notificationPort)
ret := C.fork_exec(argv0, &argvSlice[0], C.int(len(argvSlice)),
&dbp.os.task, &dbp.os.portSet, &dbp.os.exceptionPort,
&dbp.os.notificationPort)
pid = int(ret)
})
if pid <= 0 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册