Skip to content

Commit

Permalink
ogn-rf: Detect if stdin is a terminal
Browse files Browse the repository at this point in the history
Fixes #11: Version 0.2.5 crashs with SEGV if invoked by systemd.
  • Loading branch information
kerel-fs committed Feb 10, 2017
1 parent 24b72ef commit 894dc82
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ogn-rf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,17 @@ int main(int argc, char *argv[])
GSM.Start();
RF.Start();

char Cmd[128];
while(!RF.StopReq)
{ if(fgets(Cmd, 128, stdin)==0) break;
UserCommand(Cmd); }
if (isatty(fileno(stdin))) {
char Cmd[128];
while(!RF.StopReq) {
if(fgets(Cmd, 128, stdin)==0) break;
UserCommand(Cmd);
}
} else {
while(!RF.StopReq) {
sleep(1);
}
}

sleep(4);
RF.Stop();
Expand Down

0 comments on commit 894dc82

Please sign in to comment.