From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v2 1/3] support: Add support_process_state_wait
Date: Tue, 18 Feb 2020 16:17:55 +0100 [thread overview]
Message-ID: <87k14jzzz0.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <20200218140205.18263-1-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Tue, 18 Feb 2020 11:02:03 -0300")
* Adhemerval Zanella:
> +/* Wait for process PID to reach state STATE. It can be a combination of
> + multiple possible states ('process_state_running | process_state_sleeping')
> + where the function return when any of these state are observed.
> + The timeout POLL_TS might be used to wait before polling the PID status
> + information from the kernel. A NULL value will set to use a default
> + value (10000000 ns).
> + For an invalid state not represented by SUPPORT_PROCESS_STATE, it fallbacks
> + to a 2 second sleep. */
> +void support_process_state_wait (pid_t pid, enum support_process_state state,
> + struct timespec *poll_ts);
The comment should say what happens if the timeout expires. And I
believe the argument should be a const struct timespec *. But I don't
see how controlling the poll interval is useful.
> diff --git a/support/xgetline.c b/support/xgetline.c
> new file mode 100644
> index 0000000000..5b010bcf56
> --- /dev/null
> +++ b/support/xgetline.c
> @@ -0,0 +1,34 @@
> +/* fopen with error checking.
> + Copyright (C) 2016-2019 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <support/xstdio.h>
> +
> +#include <support/check.h>
> +#include <errno.h>
> +
> +ssize_t
> +xgetline (char **lineptr, size_t *n, FILE *stream)
> +{
> + int old_errno = errno;
> + errno = 0;
> + ssize_t ret = getline (lineptr, n, stream);
> + if (ret == -1 && errno != 0)
> + FAIL_EXIT1 ("getline failed: %m");
> + errno = old_errno;
> + return ret;
> +}
I think it would be clearer to use ferror to check for errors.
Rest of the patch looks okay.
Thanks,
Florian
next prev parent reply other threads:[~2020-02-18 15:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 14:02 [PATCH v2 1/3] support: Add support_process_state_wait Adhemerval Zanella
2020-02-18 14:02 ` [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666) Adhemerval Zanella
2020-02-18 17:47 ` Adhemerval Zanella
2020-02-27 16:44 ` Adhemerval Zanella
2020-02-18 14:02 ` [PATCH v2 3/3] posix: Remove posix waitid Adhemerval Zanella
2020-02-18 17:47 ` Adhemerval Zanella
2020-02-27 16:45 ` Adhemerval Zanella
2020-02-18 15:17 ` Florian Weimer [this message]
2020-02-18 17:52 ` [PATCH v2 1/3] support: Add support_process_state_wait Adhemerval Zanella
2020-02-18 17:54 ` Florian Weimer
2020-02-18 18:01 ` Adhemerval Zanella
2020-02-18 18:07 ` Florian Weimer
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k14jzzz0.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).