单声道检测 运行 是否在交互模式下 OS X
Mono detect if running in interactive mode on OS X
我正在 Mac OS X & Windows 上开发一项服务,这取决于我 运行 它是从命令行还是作为服务,它的行为有所不同.
Windows 上的这行代码工作正常
Environment.UserInteractive
但它总是 return 基于单声道源的错误:
https://github.com/mono/mono/blob/master/mcs/class/corlib/System/Environment.cs#L358
Mac OS X 是否有任何解决方法?
在单声道中查看源代码,找到了我要找的东西!
https://github.com/mono/mono/blob/master/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs#L4838
[DllImport (LIBC, EntryPoint="isatty")]
private static extern int sys_isatty (int fd);
public static bool isatty (int fd)
{
return sys_isatty (fd) == 1;
}
我正在 Mac OS X & Windows 上开发一项服务,这取决于我 运行 它是从命令行还是作为服务,它的行为有所不同.
Windows 上的这行代码工作正常
Environment.UserInteractive
但它总是 return 基于单声道源的错误:
https://github.com/mono/mono/blob/master/mcs/class/corlib/System/Environment.cs#L358
Mac OS X 是否有任何解决方法?
在单声道中查看源代码,找到了我要找的东西!
https://github.com/mono/mono/blob/master/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs#L4838
[DllImport (LIBC, EntryPoint="isatty")]
private static extern int sys_isatty (int fd);
public static bool isatty (int fd)
{
return sys_isatty (fd) == 1;
}