Determine if only one instance is running: Difference between revisions
Determine if only one instance is running (view source)
Revision as of 11:33, 25 October 2019
, 4 years agoFix formatting
(Check SocketOSException type) |
(Fix formatting) |
||
Line 374:
<lang d>import std.socket;
import std.socket;
bool is_unique_instance() {▼
{
auto socket = new Socket(AddressFamily.UNIX, SocketType.STREAM);
auto addr = new UnixAddress("\0/tmp/myapp.uniqueness.sock");
try
{
socket.bind(addr);
return true;
}
{
import core.stdc.errno : EADDRINUSE;
{
}
else
{
throw e;
}
}
}
|