Thread (6 messages) flat view 6 messages, 3 authors, 2017-02-02
STALE3474d

[PATCH] tools/btattach: Add detach option

From: Carlo Caione <hidden>
Date: 2017-02-01 17:14:31
Subsystem: the rest · Maintainer: Linus Torvalds

From: Carlo Caione <redacted>

Signed-off-by: Carlo Caione <redacted>
---
 tools/btattach.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/btattach.c b/tools/btattach.c
index 5adbc8d..f1f115d 100644
--- a/tools/btattach.c
+++ b/tools/btattach.c
@@ -194,6 +194,7 @@ static void usage(void)
 		"\t-P, --protocol <proto> Specify protocol type\n"
 		"\t-S, --speed <baudrate> Specify which baudrate to use\n"
 		"\t-N, --noflowctl        Disable flow control\n"
+		"\t-D, --detach           Open device and then fork\n"
 		"\t-h, --help             Show help options\n");
 }
 
@@ -203,6 +204,7 @@ static const struct option main_options[] = {
 	{ "protocol", required_argument, NULL, 'P' },
 	{ "speed",    required_argument, NULL, 'S' },
 	{ "noflowctl",no_argument,       NULL, 'N' },
+	{ "detach",   no_argument,       NULL, 'D' },
 	{ "version",  no_argument,       NULL, 'v' },
 	{ "help",     no_argument,       NULL, 'h' },
 	{ }
@@ -230,7 +232,7 @@ static const struct {
 int main(int argc, char *argv[])
 {
 	const char *bredr_path = NULL, *amp_path = NULL, *proto = NULL;
-	bool flowctl = true, raw_device = false;
+	bool flowctl = true, raw_device = false, detach = false;
 	sigset_t mask;
 	int exit_status, count = 0, proto_id = HCI_UART_H4;
 	unsigned int speed = B115200;
@@ -263,6 +265,9 @@ int main(int argc, char *argv[])
 		case 'N':
 			flowctl = false;
 			break;
+		case 'D':
+			detach = true;
+			break;
 		case 'R':
 			raw_device = true;
 			break;
@@ -348,6 +353,9 @@ int main(int argc, char *argv[])
 		return EXIT_FAILURE;
 	}
 
+	if (detach && fork())
+		return 0;
+
 	exit_status = mainloop_run();
 
 	return exit_status;
-- 
2.9.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help