[LTP] [PATCH] syscalls/acct02.c: Fix EMFILE error

Christian Amann camann@suse.com
Tue Jun 11 07:53:44 CEST 2019


Hi,

Nice catch! Patch makes sense and works.

Kind regards,

Christian


Tested-by: Christian Amann <camann@suse.com>

On 08/06/2019 12:27, Xiao Yang wrote:
> Running acct02 with "-i large number" option may get EMFILE error,
> because 'fd' file descriptor is not closed on each iteration.
>
> Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
> ---
>  testcases/kernel/syscalls/acct/acct02.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
> index 8a99bb9..f61faf2 100644
> --- a/testcases/kernel/syscalls/acct/acct02.c
> +++ b/testcases/kernel/syscalls/acct/acct02.c
> @@ -140,6 +140,8 @@ static void run(void)
>  		tst_res(TPASS, "acct() wrote correct file contents!");
>  	else
>  		tst_res(TFAIL, "acct() wrote incorrect file contents!");
> +
> +	SAFE_CLOSE(fd);
>  }
>  
>  static void setup(void)


More information about the ltp mailing list