mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-25 23:39:22 +02:00
tools/dirtpan/dirtpan.c: new option -b to background/daemonize
- dirtpan.c (usage): added detailed description of the arguments - dirtpan.c (usage, main): new option -b to daemonize after initialization
This commit is contained in:
parent
f5b1693a0c
commit
81a8e138c7
@ -533,7 +533,14 @@ static int open_tun(const char *cmd)
|
|||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-d [-d]] pan_id src_addr dst_addr [command]\n"
|
"usage: %s [-b] [-d [-d]] pan_id src_addr dst_addr [command]\n\n"
|
||||||
|
" pan_id PAN (network) identifier\n"
|
||||||
|
" src_addr source short address\n"
|
||||||
|
" dst_addr destination short address\n"
|
||||||
|
" command configuration command to run after creating the TUN interface.\n"
|
||||||
|
" The environment variable $ITF is set to the interface name.\n\n"
|
||||||
|
" -b background the process after initialization\n"
|
||||||
|
" -d ... increase verbosity of debug output\n"
|
||||||
, name);
|
, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -557,10 +564,14 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
const char *cmd = NULL;
|
const char *cmd = NULL;
|
||||||
uint16_t pan, src, dst;
|
uint16_t pan, src, dst;
|
||||||
|
int foreground = 1;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "d")) != EOF)
|
while ((c = getopt(argc, argv, "bd")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'b':
|
||||||
|
foreground = 0;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
debug++;
|
debug++;
|
||||||
break;
|
break;
|
||||||
@ -583,6 +594,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
net = open_net(pan, src, dst);
|
net = open_net(pan, src, dst);
|
||||||
tun = open_tun(cmd);
|
tun = open_tun(cmd);
|
||||||
|
|
||||||
|
if (foreground || !daemonize())
|
||||||
while (1)
|
while (1)
|
||||||
event();
|
event();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user