char* saveptr;
char* tok = strtok_r(buffer, "\n\r", &saveptr);
do {
- if(!cmd_q || !(*cmd_q))
- break;
+ log_printf(NOTICE, "door-firmware: %s", tok);
- send_response((*cmd_q)->fd, tok);
+ int cmd_fd = -1;
+ if(cmd_q && (*cmd_q)) {
+ cmd_fd = (*cmd_q)->fd;
+ send_response(cmd_fd, tok);
+ }
if(!strncmp(tok, "Status:", 7)) {
client_t* client;
for(client = client_lst; client; client = client->next)
- if(client->status_listener && client->fd != (*cmd_q)->fd)
+ if(client->status_listener && client->fd != cmd_fd)
send_response(client->fd, tok);
}
fclose(pid_file);
}
- int door_fd = open(opt.door_dev_, O_RDWR);
+ int door_fd = open(opt.door_dev_, O_RDWR | O_NOCTTY);
if(door_fd < 0) {
log_printf(ERROR, "unable to open %s: %s", opt.door_dev_, strerror(errno));
options_clear(&opt);