mirror of
https://github.com/eddyem/small_tel.git
synced 2026-05-01 18:37:07 +03:00
fixed bug
This commit is contained in:
@@ -3,7 +3,7 @@ LDFLAGS = -lerfa -pthread -lusefull_macros
|
|||||||
SRCS = $(wildcard *.c)
|
SRCS = $(wildcard *.c)
|
||||||
CC = gcc
|
CC = gcc
|
||||||
DEFINES = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=1111
|
DEFINES = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=1111
|
||||||
DEFINES += -DEBUG
|
#DEFINES += -DEBUG
|
||||||
CXX = gcc
|
CXX = gcc
|
||||||
CFLAGS = -Wall -Werror -Wextra -Wno-trampolines $(DEFINES)
|
CFLAGS = -Wall -Werror -Wextra -Wno-trampolines $(DEFINES)
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|||||||
@@ -47,16 +47,21 @@ extern void check4running(char *self, char *pidfilename, void (*iffound)(pid_t p
|
|||||||
// pause for incoming message waiting (out coordinates sent after that timeout)
|
// pause for incoming message waiting (out coordinates sent after that timeout)
|
||||||
#define SOCK_TMOUT (1)
|
#define SOCK_TMOUT (1)
|
||||||
|
|
||||||
static pid_t childpid = 1; // PID of child process
|
static pid_t childpid = 0; // PID of child process
|
||||||
volatile int global_quit = 0;
|
volatile int global_quit = 0;
|
||||||
// quit by signal
|
// quit by signal
|
||||||
void signals(int sig){
|
void signals(int sig){
|
||||||
signal(sig, SIG_IGN);
|
signal(sig, SIG_IGN);
|
||||||
if(!childpid){ // child process
|
if(!childpid){ // child process
|
||||||
|
DBG("STOP tel");
|
||||||
stop_telescope();
|
stop_telescope();
|
||||||
|
DBG("Disconn tel");
|
||||||
disconnect_telescope();
|
disconnect_telescope();
|
||||||
unlink(GP->pidfile); // and remove pidfile
|
DBG("Disconn weat");
|
||||||
weatherserver_disconnect();
|
weatherserver_disconnect();
|
||||||
|
}else{
|
||||||
|
DBG("Unlink PID");
|
||||||
|
unlink(GP->pidfile); // and remove pidfile
|
||||||
}
|
}
|
||||||
DBG("Get signal %d, quit.\n", sig);
|
DBG("Get signal %d, quit.\n", sig);
|
||||||
global_quit = 1;
|
global_quit = 1;
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ static char *read_string(){
|
|||||||
*/
|
*/
|
||||||
static char *write_cmd(const char *cmd, char *buff){
|
static char *write_cmd(const char *cmd, char *buff){
|
||||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
if(!TTY || TTY->comfd < 0){
|
||||||
|
DBG("TTY destroyed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
DBG("Write %s", cmd);
|
DBG("Write %s", cmd);
|
||||||
if(sl_tty_write(TTY->comfd, cmd, strlen(cmd))) return NULL;
|
if(sl_tty_write(TTY->comfd, cmd, strlen(cmd))) return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user