[PATCH] tools/btattach: Add detach option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Carlo Caione <carlo@xxxxxxxxxxxx>

Signed-off-by: Carlo Caione <carlo@xxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux