native_execve function

int native_execve(
  1. String path,
  2. Pointer<Pointer<Utf8>> __argv,
  3. Pointer<Pointer<Utf8>> __envp
)

Replace the current process, executing PATH with arguments ARGV and environment ENVP. ARGV and ENVP are terminated by NULL pointers.

Implementation

int native_execve(
  String path, // ffi.Pointer<Utf8> __path,
  ffi.Pointer<ffi.Pointer<Utf8>> __argv,
  ffi.Pointer<ffi.Pointer<Utf8>> __envp,
) {
  final cPath = path.toNativeUtf8();

  _execve ??= Libc().dylib.lookupFunction<
      ffi.Int32 Function(ffi.Pointer<Utf8>, ffi.Pointer<ffi.Pointer<Utf8>>,
          ffi.Pointer<ffi.Pointer<Utf8>>),
      _dart_execve>('execve');
  final result = _execve!(
    cPath,
    __argv,
    __envp,
  );

  malloc.free(cPath);

  return result;
}