diff --git a/.gitignore b/.gitignore index 37272fe..75ceed2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ obj/* bin/* +data/simpledb/* +data/simpledb/blocks/* diff --git a/data/simpledb/blockchain.txt b/data/simpledb/blockchain.txt deleted file mode 100644 index 769a4cb..0000000 --- a/data/simpledb/blockchain.txt +++ /dev/null @@ -1 +0,0 @@ -000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 0 diff --git a/data/simpledb/blocks/639340_00000000000000000009e3d7be64b2b867231436a3e689a0a4fabdff77398960 b/data/simpledb/blocks/639340_00000000000000000009e3d7be64b2b867231436a3e689a0a4fabdff77398960 deleted file mode 100644 index 2c5d1e0..0000000 Binary files a/data/simpledb/blocks/639340_00000000000000000009e3d7be64b2b867231436a3e689a0a4fabdff77398960 and /dev/null differ diff --git a/data/simpledb/blocks/639341_00000000000000000009f0147b38b7a37c5a8947fb18486e651274a97e4fe3d0 b/data/simpledb/blocks/639341_00000000000000000009f0147b38b7a37c5a8947fb18486e651274a97e4fe3d0 deleted file mode 100644 index d71ddd0..0000000 Binary files a/data/simpledb/blocks/639341_00000000000000000009f0147b38b7a37c5a8947fb18486e651274a97e4fe3d0 and /dev/null differ diff --git a/data/simpledb/blocks/639342_0000000000000000000f953352fedd34f666244750ea7e59c5fc35dd1b4c4ada b/data/simpledb/blocks/639342_0000000000000000000f953352fedd34f666244750ea7e59c5fc35dd1b4c4ada deleted file mode 100644 index a571cd6..0000000 Binary files a/data/simpledb/blocks/639342_0000000000000000000f953352fedd34f666244750ea7e59c5fc35dd1b4c4ada and /dev/null differ diff --git a/data/simpledb/blocks/639343_0000000000000000000f3346aa83aea5d35498357be2728f86090729e4a526a4 b/data/simpledb/blocks/639343_0000000000000000000f3346aa83aea5d35498357be2728f86090729e4a526a4 deleted file mode 100644 index 3e587a5..0000000 Binary files a/data/simpledb/blocks/639343_0000000000000000000f3346aa83aea5d35498357be2728f86090729e4a526a4 and /dev/null differ diff --git a/include/daemonize.h b/include/daemonize.h index b229bce..4040c9f 100644 --- a/include/daemonize.h +++ b/include/daemonize.h @@ -2,6 +2,6 @@ #define __MY_DAEMONIZE_H__ void daemonize(); -void log_signal_message(char*, char*); +void log_signal_message(char*); #endif diff --git a/src/daemonize.c b/src/daemonize.c index 8c9e03f..2719144 100644 --- a/src/daemonize.c +++ b/src/daemonize.c @@ -8,9 +8,9 @@ #include #include -#define RUNNING_DIR "/tmp" -#define LOCK_FILE "/tmp/daemond.lock" -#define LOG_FILE "/tmp/daemond.log" +#define RUNNING_DIR "tmp" +#define LOCK_FILE "tmp/daemond.lock" +#define LOG_FILE "tmp/daemond.log" /* * daemon.c @@ -33,9 +33,9 @@ * MA 02110-1301, USA. */ -void log_signal_message(char *filename,char *message){ +void log_signal_message(char *message){ FILE *logfile; - logfile = fopen(filename,"a"); + logfile = fopen(LOG_FILE,"a"); if(!logfile) return; fprintf(logfile,"%s",message); fclose(logfile); @@ -70,8 +70,8 @@ void daemonize(){ umask(022); lfp = open(LOCK_FILE,O_RDWR|O_CREAT,0640); - if(lfp < 0) exit(1); - if(lockf(lfp,F_TLOCK,0) < 0) exit(1); + if(lfp < 0) { log_signal_message("daemond is allready running !\n");exit(1); } + if(lockf(lfp,F_TLOCK,0) < 0) { log_signal_message("daemond is allready running\n");exit(1); } sprintf(str,"%d\n",getpid()); write(lfp,str,strlen(str)); diff --git a/src/spy.c b/src/spy.c index 4c646ba..85c8a00 100644 --- a/src/spy.c +++ b/src/spy.c @@ -27,6 +27,9 @@ FILE* blockchain_fd = NULL; * Les outils */ static void signal_handler(int sig){ + char msg[200]; + sprintf(msg,"process %d signal %d trapped\n", getpid(), sig); + log_signal_message(msg); switch(sig){ case SIGUSR1: // signal USR1 diff --git a/src/test_daemonize.c b/src/test_daemonize.c index 8c72aa2..db4a277 100644 --- a/src/test_daemonize.c +++ b/src/test_daemonize.c @@ -16,7 +16,7 @@ static void signal_handler(int sig){ char msg[200]; sprintf(msg,"process %d signal %d trapped\n", getpid(), sig); - log_signal_message("/tmp/daemonize.log", msg); + log_signal_message(msg); switch(sig){ case SIGUSR1: diff --git a/tmp/Makefile b/tmp/Makefile deleted file mode 100644 index 4f1ecb1..0000000 --- a/tmp/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -CC=gcc -IFLAGS=-I /usr/local/include/btc -CFLAGS=-g -LDFLAGS=-lbtc -OBJDIR=obj -BINDIR=bin -SRCDIR=src - -all: $(OBJDIR) $(BINDIR) $(EXE) - -$(OBJDIR): - mkdir -p $(OBJDIR) - -$(BINDIR): - mkdir -p $(BINDIR) - -$(OBJDIR)/%.o : $(SRCDIR)/%.c | $(OBJDIR) $(BINDIR) - $(CC) $(IFLAGS) -o $@ -c $< $(CFLAGS) - -.PHONY: clean mrproper $(EXE) - -clean: - rm -f $(OBJDIR)/*.o - -mrproper : clean - rm -rf $(OBJDIR) - rm -rf $(BINDIR) diff --git a/tmp/daemond.log b/tmp/daemond.log new file mode 100644 index 0000000..e38c268 --- /dev/null +++ b/tmp/daemond.log @@ -0,0 +1 @@ +process 11096 signal 15 trapped