From 9d58bf1694fe1acff90f32179e6501555f43e2db Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Thu, 2 Apr 2026 12:00:43 +0300 Subject: [PATCH] fixed bug --- .../deprecated/10micron_stellarium.deprecated/Makefile | 2 +- Daemons/deprecated/10micron_stellarium.deprecated/main.c | 9 +++++++-- .../10micron_stellarium.deprecated/telescope.c | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Daemons/deprecated/10micron_stellarium.deprecated/Makefile b/Daemons/deprecated/10micron_stellarium.deprecated/Makefile index 1219130..1e14e4b 100644 --- a/Daemons/deprecated/10micron_stellarium.deprecated/Makefile +++ b/Daemons/deprecated/10micron_stellarium.deprecated/Makefile @@ -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) diff --git a/Daemons/deprecated/10micron_stellarium.deprecated/main.c b/Daemons/deprecated/10micron_stellarium.deprecated/main.c index 80556ab..c837ddb 100644 --- a/Daemons/deprecated/10micron_stellarium.deprecated/main.c +++ b/Daemons/deprecated/10micron_stellarium.deprecated/main.c @@ -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; diff --git a/Daemons/deprecated/10micron_stellarium.deprecated/telescope.c b/Daemons/deprecated/10micron_stellarium.deprecated/telescope.c index 1caa991..de694ad 100644 --- a/Daemons/deprecated/10micron_stellarium.deprecated/telescope.c +++ b/Daemons/deprecated/10micron_stellarium.deprecated/telescope.c @@ -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;