Skip to contentSkip to conversation

shared/shell: Add support for -EINPROGRESS to bt_shell_noninteractive_quit

PATCH Applied Luiz Augusto von Dentz 3 participants 4 messages Jun 5, 2025 – Jun 6, 2025 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/2 shared/shell: Add support for -EINPROGRESS to bt_shell_noninteractive_quit

From: Luiz Augusto von Dentz <[email protected]>

This enables commands to call bt_shell_noninteractive_quit with status set to -EINPROGRESS to indicate their execution is in progress and shall not exit in case of MODE_NONINTERACTIVE but it can proceed to the next command for MODE_INTERACTIVE.

---
 src/shared/shell.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/shared/shell.c +6 -0
index 3e5959fc1868..6b4f7a7ef503 100644
@@ -1560,6 +1560,12 @@ void bt_shell_noninteractive_quit(int status)
 		return;
 	}
 
+	/* Ignore EINPROGRESS as it is meant for commands that need to stay
+	 * running.
+	 */
+	if (status == -EINPROGRESS)
+		return;
+
 	bt_shell_quit(status);
 }
 
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v2 2/2 client: Use -EINPROGRESS with scan and advertise command

From: Luiz Augusto von Dentz <[email protected]>

This uses -EINPROGRESS with commands scan and advertise since they need to keep running in the background so they don't exit but shouldn't block other command from executing in case they are invoked from a script.

---
 client/advertising.c | 9 ++-------
 client/main.c        | 3 ++-
 2 files changed, 4 insertions(+), 8 deletions(-)
client/advertising.c +2 -7
index 382ae420e663..f9df1b855cde 100644
@@ -18,6 +18,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <string.h>
+#include <errno.h>
 
 #include "gdbus/gdbus.h"
 #include "src/shared/util.h"
@@ -238,7 +239,7 @@ static void register_reply(DBusMessage *message, void *user_data)
 		ad.registered = true;
 		bt_shell_printf("Advertising object registered\n");
 		print_ad();
-		/* Leave advertise running even on noninteractive mode */
+		return bt_shell_noninteractive_quit(-EINPROGRESS);
 	} else {
 		bt_shell_printf("Failed to register advertisement: %s\n", error.name);
 		dbus_error_free(&error);
@@ -874,8 +875,6 @@ static void ad_clear_service(int type)
 {
 	g_free(ad.service[type].uuid);
 	memset(&ad.service[type], 0, sizeof(ad.service[type]));
-
-	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
 
 static bool ad_add_data(struct ad_data *data, int argc, char *argv[])
@@ -950,8 +949,6 @@ void ad_disable_service(DBusConnection *conn, int type)
 static void ad_clear_manufacturer(int type)
 {
 	memset(&ad.manufacturer[type], 0, sizeof(ad.manufacturer[type]));
-
-	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
 
 void ad_advertise_manufacturer(DBusConnection *conn, int type,
@@ -1006,8 +1003,6 @@ void ad_disable_manufacturer(DBusConnection *conn, int type)
 static void ad_clear_data(int type)
 {
 	memset(&ad.data[type], 0, sizeof(ad.data[type]));
-
-	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
 
 void ad_advertise_data(DBusConnection *conn, int type, int argc, char *argv[])
client/main.c +2 -1
index c2321952bd4f..d99a5158e35a 100644
@@ -1219,7 +1219,8 @@ static void start_discovery_reply(DBusMessage *message, void *user_data)
 	bt_shell_printf("Discovery %s\n", enable ? "started" : "stopped");
 
 	filter.active = enable;
-	/* Leave the discovery running even on noninteractive mode */
+
+	return bt_shell_noninteractive_quit(-EINPROGRESS);
 }
 
 static void clear_discovery_filter(DBusMessageIter *iter, void *user_data)
Signature · 1 line
2.49.0
#2 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=969046

---Test result---

Test Summary:

CheckPatch                    PENDING   0.27 seconds
GitLint                       PENDING   0.35 seconds
BuildEll                      PASS      20.44 seconds
BluezMake                     PASS      2696.22 seconds
MakeCheck                     PASS      19.90 seconds
MakeDistcheck                 PASS      201.06 seconds
CheckValgrind                 PASS      277.43 seconds
CheckSmatch                   WARNING   301.60 seconds
bluezmakeextell               PASS      128.65 seconds
IncrementalBuild              PENDING   0.22 seconds
ScanBuild                     PASS      917.34 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:

---
Regards,
Linux Bluetooth

#3 lore raw
In reply to Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 8 lines · On Thu, 5 Jun 2025 15:24:05 -0400 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This enables commands to call bt_shell_noninteractive_quit with status set to -EINPROGRESS to indicate their execution is in progress and shall not exit in case of MODE_NONINTERACTIVE but it can proceed to the next command for MODE_INTERACTIVE.

[...]

Here is the summary with links:
- [BlueZ,v2,1/2] shared/shell: Add support for -EINPROGRESS to bt_shell_noninteractive_quit

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7d59391bb783
  - [BlueZ,v2,2/2] client: Use -EINPROGRESS with scan and advertise command
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5499681bc632

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html