fixed bug

This commit is contained in:
2026-04-02 12:00:43 +03:00
parent a324302404
commit 9d58bf1694
3 changed files with 12 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ LDFLAGS = -lerfa -pthread -lusefull_macros
SRCS = $(wildcard *.c)
CC = gcc
DEFINES = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=1111
DEFINES += -DEBUG
#DEFINES += -DEBUG
CXX = gcc
CFLAGS = -Wall -Werror -Wextra -Wno-trampolines $(DEFINES)
OBJS = $(SRCS:.c=.o)

View File

@@ -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)
#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;
// quit by signal
void signals(int sig){
signal(sig, SIG_IGN);
if(!childpid){ // child process
DBG("STOP tel");
stop_telescope();
DBG("Disconn tel");
disconnect_telescope();
unlink(GP->pidfile); // and remove pidfile
DBG("Disconn weat");
weatherserver_disconnect();
}else{
DBG("Unlink PID");
unlink(GP->pidfile); // and remove pidfile
}
DBG("Get signal %d, quit.\n", sig);
global_quit = 1;

View File

@@ -113,6 +113,10 @@ static char *read_string(){
*/
static char *write_cmd(const char *cmd, char *buff){
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
if(!TTY || TTY->comfd < 0){
DBG("TTY destroyed");
return NULL;
}
pthread_mutex_lock(&mutex);
DBG("Write %s", cmd);
if(sl_tty_write(TTY->comfd, cmd, strlen(cmd))) return NULL;