[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: csplit 'write error' missing errno?
From: |
Pádraig Brady |
Subject: |
Re: csplit 'write error' missing errno? |
Date: |
Wed, 11 Nov 2015 15:40:10 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 11/11/15 15:18, Assaf Gordon wrote:
>
> Attached an improved test, this time using '/dev/full' (if exists) to get the
> wording for the ENOSPC errno, then verify the error message from csplit.
heh nice.
comments below...
> diff --git a/tests/misc/csplit-io-err.sh b/tests/misc/csplit-io-err.sh
> +# Replace fwrite and ferror, always returning an error
> +cat > k.c <<'EOF' || framework_failure_
> +#include <stdio.h>
> +#include <errno.h>
> +
> +#undef fwrite
> +#undef fwrite_unlocked
> +
> +size_t
> +fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream)
> +{
> + fclose (fopen ("preloaded","w")); /* marker for preloaded interception */
> + errno = ENOSPC;
> + return 0;
> +}
> +
> +size_t
> +fwrite_unlocked (const void *ptr, size_t size, size_t nitems, FILE *stream)
> +{
> + fclose (fopen ("preloaded","w")); /* marker for preloaded interception */
> + errno = ENOSPC;
> + return 0;
Maybe replace the above 3 lines with:
return fwrite (ptr, size, nitems, stream);
> +# Create the expected error message
> +( printf "%s" "csplit: write error for 'xx01': " ; cat msg ) > exp \
> + || framework_failure_
It's better to use { cmd; } than ( cmd ) here
as some shell will avoid a subshell in that case.
please push after those tweaks.
thanks!
Pádraig