I need to call this procedure through PInvoke in the mono application. Just name of library please.
Being part of the GNU C lib it is in libc
:
using System;
using System.Runtime.InteropServices;
namespace posix
{
class MainClass
{
[DllImport ("libc", SetLastError=true)]
private static extern int system (string exec);
[DllImport ("libc", SetLastError=true)]
public static extern int execv (string path, string[] argv);
public static void Main (string[] args)
{
Console.WriteLine ("Error:{0}", system ("ls -l"));
Console.WriteLine ("Error:{0}", execv ("/usr/bin/vi", new string[] { "/usr/bin/vi" , "foobar.txt" }));
// Of course, being execv without failure we never come back...
Console.WriteLine ("Should never be displayed");
Console.WriteLine ("Error:{0}", Mono.Unix.Native.Syscall.execv ("/usr/bin/ls", new string[] { "/usr/bin/ls" }));
}
}
}