Skip to content
Snippets Groups Projects
Commit c7153d34 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Create POSIX static class for missing functionality in .NET lib

parent 72543e91
No related branches found
No related tags found
No related merge requests found
...@@ -20,13 +20,21 @@ using Process = System.Diagnostics.Process; ...@@ -20,13 +20,21 @@ using Process = System.Diagnostics.Process;
using Config; using Config;
namespace i3csstatus { namespace i3csstatus {
static class ProcesExtended static class POSIX
{ {
[DllImport("libc", SetLastError = true)] [DllImport("libc", SetLastError = true)]
public static extern int mkfifo(string path, int mode);
[DllImport("libc", CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
public static extern int kill(int pid, int sig); public static extern int kill(int pid, int sig);
public static int SIGUSR1 = 10;
public static int EEXIST = 17;
public static int ERRNO { get => Marshal.GetLastPInvokeError();}
}
static class ProcesExtended
{
public static int KillBySignal(this Process p, int sig) public static int KillBySignal(this Process p, int sig)
{ {
return kill(p.Id, sig); return POSIX.kill(p.Id, sig);
} }
} }
static class JsonExtended static class JsonExtended
...@@ -247,7 +255,7 @@ text = ERR ...@@ -247,7 +255,7 @@ text = ERR
if(lastGet_ms + cache_ms > t) if(lastGet_ms + cache_ms > t)
return; return;
lastGet_ms = t; lastGet_ms = t;
process.KillBySignal(10); process.KillBySignal(POSIX.SIGUSR1);
string line = process.StandardOutput.ReadLine(); string line = process.StandardOutput.ReadLine();
if(line == null) if(line == null)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment