Skip to content

Commit c059eea

Browse files
author
=
committed
added option to daemonize hcxdumptool - see -h for more information
1 parent c6da359 commit c059eea

3 files changed

Lines changed: 45 additions & 1 deletion

File tree

changelog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
18.12.2025
2+
==========
3+
hcxdumptool: added option to daemonize hcxdumptool
4+
--daemonize : daemonize
5+
status messages are suppressed
6+
to terminate hcxdumptool send SIGTERM to its PID
7+
or press push button (modified Raspberry Pi)
8+
9+
110
05.11.2025
211
==========
312
hcxdumptool: added waterfall status display mode (rds=4)

hcxdumptool.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static int gpiostatusled = 0;
7373
static int gpiobutton = 0;
7474

7575
static pid_t hcxpid = 0;
76+
static pid_t hcxsid = 0;
7677

7778
static unsigned int seed = 7;
7879

@@ -5373,8 +5374,13 @@ fprintf(stdout, "--tot=<digit> : enable timeout timer in minutes\n"
53735374
" default: 0 (GPIO not in use)\n"
53745375
"--gpio_statusled=<digit> : Raspberry Pi GPIO number of status LED (2...27)\n"
53755376
" default: 0 (GPIO not in use)\n"
5377+
"--daemonize : daemonize\n"
5378+
" status messages are suppressed\n"
5379+
" to terminate %s send SIGTERM to its PID\n"
5380+
" or press push button (modified Raspberry Pi)\n"
53765381
"--help : show additional help (example and trouble shooting)\n"
5377-
"--version : show version\n\n");
5382+
"--version : show version\n\n",
5383+
eigenname);
53785384
exit(EXIT_SUCCESS);
53795385
}
53805386
/*---------------------------------------------------------------------------*/
@@ -5418,6 +5424,8 @@ static bool interfacefrequencyflag = false;
54185424
static bool interfacelistflag = false;
54195425
static bool interfacelistshortflag = false;
54205426
static bool rooterrorflag = false;
5427+
static bool daemon = false;
5428+
54215429
static char *essidlistname = NULL;
54225430
static char *userchannellistname = NULL;
54235431
static char *userfrequencylistname = NULL;
@@ -5451,6 +5459,7 @@ static const struct option long_options[] =
54515459
{"gpio_statusled", required_argument, NULL, HCX_GPIO_STATUSLED},
54525460
{"rds", required_argument, NULL, HCX_RDS},
54535461
{"rdt", no_argument, NULL, HCX_RDT},
5462+
{"daemonize", no_argument, NULL, HCX_DAEMON},
54545463
{"rcascan", required_argument, NULL, HCX_RCASCAN},
54555464
{"version", no_argument, NULL, HCX_VERSION},
54565465
{"help", no_argument, NULL, HCX_HELP_ADDITIONAL},
@@ -5697,7 +5706,10 @@ while((auswahl = getopt_long(argc, argv, short_options, long_options, &index)) !
56975706
fprintf(stderr, "combination of --rcascan and -w is not allowed\n");
56985707
exit(EXIT_FAILURE);
56995708
}
5709+
break;
57005710

5711+
case HCX_DAEMON:
5712+
daemon = true;
57015713
break;
57025714

57035715
case HCX_HELP:
@@ -5869,6 +5881,28 @@ if(set_timer() == false)
58695881
fprintf(stderr, "failed to initialize timer\n");
58705882
goto byebye;
58715883
}
5884+
5885+
if(daemon == true)
5886+
{
5887+
if((hcxpid = fork()) < 0)
5888+
{
5889+
fprintf(stdout, "failed to daamonize %s\n", basename(argv[0]));
5890+
goto byebye;
5891+
}
5892+
if(hcxpid > 0)
5893+
{
5894+
fprintf(stdout, "daemonize %s (pid: %d)\n", basename(argv[0]), hcxpid);
5895+
goto byebye;
5896+
}
5897+
if((hcxsid = setsid()) < 0)
5898+
{
5899+
fprintf(stdout, "failed to daemonize %s\n", basename(argv[0]));
5900+
goto byebye;
5901+
}
5902+
close(STDIN_FILENO);
5903+
close(STDOUT_FILENO);
5904+
close(STDERR_FILENO);
5905+
}
58725906
/*---------------------------------------------------------------------------*/
58735907
tspecifo.tv_sec = 5;
58745908
tspecifo.tv_nsec = 0;

include/hcxdumptool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define HCX_RDS 22
2626
#define HCX_RDT 23
2727
#define HCX_RCASCAN 24
28+
#define HCX_DAEMON 25
2829
#define HCX_IFNAME 'i'
2930
#define HCX_PCAPNGNAME 'w'
3031
#define HCX_INTERFACE_INFO 'I'

0 commit comments

Comments
 (0)