From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH 1/3] syscalls: refactor fork09 using new API
Date: Tue, 27 Jan 2026 15:31:36 +0100 [thread overview]
Message-ID: <20260127143136.GA153805@pevik> (raw)
In-Reply-To: <20260127-fork_refactoring-v1-1-e3e21ff1a4f7@suse.com>
Hi Andrea,
Generally LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> + tst_res(TINFO, "Opening files from parent");
> +
> + for (nfiles = 0; nfiles < file_open_max; nfiles++) {
> + memset(name, 0, PATH_MAX);
> + snprintf(name, PATH_MAX, "%s%lu", FILE_PREFIX, nfiles);
> - /* clean up things in case we are looping */
> - for (nf = first; nf < nfiles; nf++) {
> - fclose(fildeses[nf]);
> - sprintf(filname, "file%d.%d", nf, mypid);
> - unlink(filname);
> + f = fopen(name, "a");
> + if (!f) {
nit: Although EMFILE meaning is quite obvious I found previous comment about
OPEN_MAX useful.
> + if (errno == EMFILE)
> + break;
> +
> + tst_brk(TBROK | TERRNO, "fopen() error");
I suppose we are ok to not close these open files even if it fails close to
OPEN_MAX...
> }
> +
> + open_files[nfiles] = f;
> + }
> +
> + totfiles = nfiles;
> +
> + if (!totfiles)
> + tst_brk(TBROK, "Parent couldn't open any file");
> +
> + tst_res(TINFO, "Closing %lu files from child", totfiles);
> +
> + if (!SAFE_FORK()) {
> + for (nfiles = nfiles - 1; nfiles >= 0; nfiles--)
> + SAFE_FCLOSE(open_files[nfiles]);
> +
> + exit(0);
> }
> + tst_reap_children();
> +
> + tst_res(TPASS, "Child closed all parent's files");
> +
... because this is not in a cleanup.
> + for (nfiles = 0; nfiles < totfiles; nfiles++) {
> + memset(name, 0, PATH_MAX);
> + snprintf(name, PATH_MAX, "%s%lu", FILE_PREFIX, nfiles);
> +
> + SAFE_FCLOSE(open_files[nfiles]);
> + SAFE_UNLINK(name);
> + }
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-01-27 14:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 12:50 [LTP] [PATCH 0/3] Refactor tests which are verifying fork/vfork functionalities Andrea Cervesato
2026-01-27 12:50 ` [LTP] [PATCH 1/3] syscalls: refactor fork09 using new API Andrea Cervesato
2026-01-27 14:31 ` Petr Vorel [this message]
2026-02-16 12:42 ` Cyril Hrubis
2026-01-27 12:50 ` [LTP] [PATCH 2/3] syscalls: refactor vfork01 " Andrea Cervesato
2026-02-16 13:07 ` Cyril Hrubis
2026-01-27 12:50 ` [LTP] [PATCH 3/3] syscalls: refactor vfork02 " Andrea Cervesato
2026-02-16 13:20 ` Cyril Hrubis
2026-03-04 14:18 ` Andrea Cervesato via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260127143136.GA153805@pevik \
--to=pvorel@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox