[RFC,v3,4/9] libcamera: process: Return error if already running
diff mbox

Message ID 20250325180821.1456154-5-barnabas.pocze@ideasonboard.com
State New
Headers show

Commit Message

Barnabás Pőcze March 25, 2025, 6:08 p.m. UTC
Returning 0 when a running process is already managed can be
confusing since the parameters might be completely different,
causing the caller to mistakenly assume that the program it
specified has been started.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/libcamera/process.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham March 25, 2025, 7:13 p.m. UTC | #1
Quoting Barnabás Pőcze (2025-03-25 18:08:16)
> Returning 0 when a running process is already managed can be
> confusing since the parameters might be completely different,
> causing the caller to mistakenly assume that the program it
> specified has been started.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/libcamera/process.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp
> index aa9e8f519..716523acc 100644
> --- a/src/libcamera/process.cpp
> +++ b/src/libcamera/process.cpp
> @@ -241,7 +241,7 @@ int Process::start(const std::string &path,
>         int ret;
>  
>         if (pid_ > 0)
> -               return 0;
> +               return -EBUSY;

Seems reasonable. I assume we don't hit this anywhere currently ;-)


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>  
>         int childPid = fork();
>         if (childPid == -1) {
> -- 
> 2.49.0
>
Laurent Pinchart March 26, 2025, 1:06 p.m. UTC | #2
Hi Barnabás,

Thank you for the patch.

On Tue, Mar 25, 2025 at 07:08:16PM +0100, Barnabás Pőcze wrote:
> Returning 0 when a running process is already managed can be
> confusing since the parameters might be completely different,
> causing the caller to mistakenly assume that the program it
> specified has been started.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/process.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp
> index aa9e8f519..716523acc 100644
> --- a/src/libcamera/process.cpp
> +++ b/src/libcamera/process.cpp
> @@ -241,7 +241,7 @@ int Process::start(const std::string &path,
>  	int ret;
>  
>  	if (pid_ > 0)
> -		return 0;
> +		return -EBUSY;
>  
>  	int childPid = fork();
>  	if (childPid == -1) {

Patch
diff mbox

diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp
index aa9e8f519..716523acc 100644
--- a/src/libcamera/process.cpp
+++ b/src/libcamera/process.cpp
@@ -241,7 +241,7 @@  int Process::start(const std::string &path,
 	int ret;
 
 	if (pid_ > 0)
-		return 0;
+		return -EBUSY;
 
 	int childPid = fork();
 	if (childPid == -1) {