Skip to content

Commit

Permalink
Don't fail if a fifo already exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarfmaster committed Jun 9, 2014
1 parent 7e8a43a commit 919cd8d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ static const char* _fifo_path = "/tmp/notifier.fifo";

int init_fifo()
{
struct stat buffer;

if(_fifo >= 0)
return 1;

if(has_entry("global.fifo"))
_fifo_path = get_string("global.fifo");
if(mkfifo(_fifo_path, 0777) != 0)
if(stat(_fifo_path, &buffer) < 0) {
if(mkfifo(_fifo_path, 0777) != 0)
return 0;
}
else if(!S_ISFIFO(buffer.st_mode))
return 0;

_fifo = open(_fifo_path, O_RDWR | O_NONBLOCK);
Expand Down

0 comments on commit 919cd8d

Please sign in to comment.