0
我知道可以使用Mono在Linux中编写C#.NET应用程序。但是,我想知道Linux的进程接口。我可以使用诸如getpid()
,getppid()
和fork()
这样的服务,使用C#和Mono并在Linux环境中运行吗?在Mono中使用C#的Linux进程API
我知道可以使用Mono在Linux中编写C#.NET应用程序。但是,我想知道Linux的进程接口。我可以使用诸如getpid()
,getppid()
和fork()
这样的服务,使用C#和Mono并在Linux环境中运行吗?在Mono中使用C#的Linux进程API
为getpid()
和getppid()
,你可以以这种方式使用Syscall:
using System;
using Mono.Unix.Native;
namespace StackOverflow
{
class MainClass
{
public static void Main(string[] args)
{
int pid = Syscall.getpid();
int ppid = Syscall.getppid();
Console.WriteLine ("PID: {0}", pid);
Console.WriteLine ("PPID: {0}", ppid);
}
}
}
你需要Mono.Posix.dll
对于fork()
可以使用Process。请参阅示例:creating child process with C#
有关Process Class C#的文档。
您是否真的需要产生新的系统进程,或者是否足以在Mono VM中拥有托管线程? – knittl 2014-09-21 17:56:21