Closed kjpgit closed 1 year ago
Same with Mono.Posix.NETStandard 1.0.
188813 execve("vim", ["hello.txt", "", "\20\235\356\317jU", 0x191], 0x7ffe670a4818 / 39 vars /) = -1 EFAULT (Bad address)
I'm hoping this isn't an 18 year old cursed comment?
**// TODO: does Mono marshal arrays properly?**
[DllImport (LIBC, SetLastError=true)]
public static extern int execve (
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
string path, string[] argv, string[] envp);
I figured it out. The string[] arrays need a NULL in the last element.
using Mono.Unix.Native;
string program = "vim"; string[] args = {"hello.txt", ""}; int ret = Syscall.execv(program, args);
strace: 187570 execve("vim", ["hello.txt", "", 0x7fc16f6e6e00, 0x81], 0x7ffcfed411c8 / 39 vars /) = -1 EFAULT (Bad address)
.net 8 preview 7, linux, "Mono.Posix" Version="7.1.0-final.1.21458.1"