lkml.org 
[lkml]   [1998]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: A fifo and signal bug
Date
> 
>
>
> On Sat, 21 Nov 1998, Michael K Vance wrote:
> >
> > Fails here.
> >
> > glibc 2.0.7
>
> It seems to have the buggy glibc "sleep()" implementation.
>
> hjl, please fix "sleep()" in glibc first. If it still fails for you, then
> I can look at it, right now I can see it failing in the strace on the
> sleep().
>

That is not true. Here is a different test case. There are 2 programs,
reader and writer. Please first start writer:

# ./writer

Then in another window, please start reader:

# ./reader

Now reader is in the blocking mode in fifo_open. Now suspend ./reader

# ./reader
zsh: 5744 suspended ./reader

After that, type RETURN in the ./writer window:

# ./writer

open: Device not configured

The problem is when the kernel suspends ./reader, it removes all traces
of ./reader from the fifo inode. When the ./writer opens the fifo in
the non-blocking mode, the kernel doesn't know the ./reader and return
ENXIO.


--
H.J. Lu (hjl@gnu.org)
----
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1998-11-21 10:49 PST by <hjl@ocean.lucon.org>.
# Source directory was `/home/hjl/bugs/glibc/signal'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 231 -rw-r--r-- reader.c
# 503 -rw-r--r-- writer.c
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
if test "$gettext_dir" = FAILED && test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
set `$dir/gettext --version 2>&1`
if test "$3" = GNU
then
gettext_dir=$dir
fi
fi
if test "$locale_dir" = FAILED && test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
echo=echo
else
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh05748; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= reader.c ==============
if test -f 'reader.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'reader.c' '(file already exists)'
else
$echo 'x -' extracting 'reader.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'reader.c' &&
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
X
#define FIFO_FILE "test.fifo"
X
main ()
{
X int fd;
X
X fd = open(FIFO_FILE, O_RDONLY);
X if (fd < 0)
X {
X perror ("open");
X return 1;
X }
X
X return 0;
}
SHAR_EOF
$shar_touch -am 1121104398 'reader.c' &&
chmod 0644 'reader.c' ||
$echo 'restore of' 'reader.c' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'reader.c:' 'MD5 check failed'
5630fd35bee148e122a309670a614687 reader.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'reader.c'`"
test 231 -eq "$shar_count" ||
$echo 'reader.c:' 'original size' '231,' 'current size' "$shar_count!"
fi
fi
# ============= writer.c ==============
if test -f 'writer.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'writer.c' '(file already exists)'
else
$echo 'x -' extracting 'writer.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'writer.c' &&
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
X
#define FIFO_FILE "test.fifo"
X
int
main (int argc, char **argv)
{
X int ret;
X int fd;
X
X unlink (FIFO_FILE);
X if (mkfifo (FIFO_FILE, S_IRWXU|S_IRWXG|S_IRWXO) != 0)
X {
X perror ("mkfifo");
X exit (1);
X }
X
X ret = getchar ();
X
X fd = open(FIFO_FILE, O_WRONLY|O_NONBLOCK);
X if (fd < 0)
X {
X perror ("open");
X }
X else
X close (fd);
X
X unlink (FIFO_FILE);
X return ret;
}
SHAR_EOF
$shar_touch -am 1121104798 'writer.c' &&
chmod 0644 'writer.c' ||
$echo 'restore of' 'writer.c' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'writer.c:' 'MD5 check failed'
9dd066a1c209bc0d8eab21999fb4541a writer.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'writer.c'`"
test 503 -eq "$shar_count" ||
$echo 'writer.c:' 'original size' '503,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh05748
exit 0

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:0.080 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site