[Pcsclite-muscle] [PATCH 1/1] pcscdaemon: fix "at_exit() write() failed: Bad file descriptor"

Ludovic Rousseau ludovic.rousseau
Sun Aug 9 01:27:05 PDT 2015


2015-08-05 17:03 GMT+02:00 Herve Codina <Herve.CODINA at celad.com>:
> In case of receiving a signal to terminate after init has been completed,
> at_exit() is called and tries to write to a closed pipe.
>
> This patch simply set pipe to -1 in order to invalidate it after closing.
> Pipe value checks are allready present in the code.
>
> Signed-off-by: Herve Codina <Herve.CODINA at celad.com>
> ---
>  src/pcscdaemon.c |    2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/pcscdaemon.c b/src/pcscdaemon.c
> index 27ee6c9..78b65b8 100644
> --- a/src/pcscdaemon.c
> +++ b/src/pcscdaemon.c
> @@ -681,6 +681,7 @@ int main(int argc, char **argv)
>                         Log2(PCSC_LOG_ERROR, "write() failed: %s", strerror(errno));
>                 }
>                 close(pipefd[1]);
> +               pipefd[1] = -1;
>         }
>
>         SVCServiceRunLoop();
> @@ -708,6 +709,7 @@ static void at_exit(void)
>                         Log2(PCSC_LOG_ERROR, "write() failed: %s", strerror(errno));
>                 }
>                 close(pipefd[1]);
> +               pipefd[1] = -1;
>         }
>
>         exit(ExitValue);
> --

Fixed in revision 79410aac02a370d6d92106c015f01ec1491d31ac
https://anonscm.debian.org/cgit/pcsclite/PCSC.git/commit/?id=79410aac02a370d6d92106c015f01ec1491d31ac

Setting pipefd[1] = -1 just before the exit() is not necessary. So I skipped it.

Thanks

-- 
 Dr. Ludovic Rousseau




More information about the pcsclite-muscle mailing list