From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v2 1/3] support: Add support_process_state_wait
Date: Tue, 18 Feb 2020 17:52:00 -0000 [thread overview]
Message-ID: <ea7e58e1-230c-2b22-bcb5-02cb1cf19f02@linaro.org> (raw)
In-Reply-To: <87k14jzzz0.fsf@oldenburg2.str.redhat.com>
On 18/02/2020 12:17, Florian Weimer wrote:
> * 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.
Thinking twice the poll interval really does not add much here,
I have removed it.
>
>> 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.
Maybe:
if (ret == -1 || ferror (stream))
...
?
>
> Rest of the patch looks okay.
>
> Thanks,
> Florian
>
next prev parent reply other threads:[~2020-02-18 17:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 14:02 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:45 ` Adhemerval Zanella
2020-02-18 14:02 ` [PATCH v2 3/3] posix: Remove posix waitid Adhemerval Zanella
2020-02-18 17:48 ` Adhemerval Zanella
2020-02-27 16:45 ` Adhemerval Zanella
2020-02-18 15:18 ` [PATCH v2 1/3] support: Add support_process_state_wait Florian Weimer
2020-02-18 17:52 ` Adhemerval Zanella [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea7e58e1-230c-2b22-bcb5-02cb1cf19f02@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--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).