diff options
author | Max Krasnyansky <maxk@qualcomm.com> | 2002-05-31 17:14:39 +0000 |
---|---|---|
committer | Max Krasnyansky <maxk@qualcomm.com> | 2002-05-31 17:14:39 +0000 |
commit | 940d830204a87da484eec5e84f18281476c9a505 (patch) | |
tree | 842673cb3476cf193669952d55d774b667e487fd | |
parent | ce0f133679d1536162c8223ea12eb582bbcafa85 (diff) |
-p print pid option
-rw-r--r-- | tools/hciattach.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/hciattach.c b/tools/hciattach.c index a7f89e21..9668460c 100644 --- a/tools/hciattach.c +++ b/tools/hciattach.c @@ -647,30 +647,36 @@ extern char *optarg; int main(int argc, char *argv[]) { struct uart_t *u = NULL; - int detach, opt, i, n; + int detach, printpid, opt, i, n; int to = 5; + pid_t pid; struct sigaction sa; char dev[20]; detach = 1; + printpid = 0; - while ((opt=getopt(argc, argv, "nt:l")) != EOF) { + while ((opt=getopt(argc, argv, "npt:l")) != EOF) { switch(opt) { case 'n': detach = 0; break; - + + case 'p': + printpid = 1; + break; + case 't': to = atoi(optarg); break; - + case 'l': for (i = 0; uart[i].type; i++) { printf("%-10s0x%04x,0x%04x\n", uart[i].type, uart[i].m_id, uart[i].p_id); } exit(0); - + default: usage(); exit(1); @@ -747,7 +753,11 @@ int main(int argc, char *argv[]) alarm(0); if (detach) { - if (fork()) return 0; + if ((pid = fork())) { + if (printpid) + printf("%d\n", pid); + return 0; + } for (i=0; i<20; i++) if (i != n) close(i); } |