?RCS: $Id: nblock_io.U,v 3.0.1.2 1997/02/28 16:17:14 ram Exp $
?RCS:
?RCS: Copyright (c) 1991-1993, Raphael Manfredi
-?RCS:
-?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
-?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 3.0.
?RCS:
?RCS: $Log: nblock_io.U,v $
?X: Simplify here document for shells that can't handle them well.
?X: (Problem reported on FreeBSD; it's unclear if this helps.) --AD
?X:
-?MAKE:o_nonblock eagain rd_nodata d_eofnblk: cat rm Compile run \
+?MAKE:o_nonblock eagain rd_nodata d_eofnblk: cat rm_try Compile run \
d_open3 h_sysfile h_fcntl signal_t hint Oldconfig Setvar \
- startsh i_unistd i_string i_fcntl
+ startsh i_unistd i_string i_fcntl i_stdlib d_fork d_pipe
?MAKE: -pick add $@ %<
?S:o_nonblock:
?S: This variable bears the symbol value to be used during open() or fcntl()
?H:#define RD_NODATA $rd_nodata
?H:#$d_eofnblk EOF_NONBLOCK
?H:.
-?F:!try.out !try.ret !try.err
?T:status
+?F:!try.out !try.ret !try.err !try !mtry
?LINT:use d_open3
: check for non-blocking I/O stuff
case "$h_sysfile" in
$cat head.c > try.c
$cat >>try.c <<EOCP
#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
#include <stdlib.h>
+#endif
#$i_fcntl I_FCNTL
#ifdef I_FCNTL
#include <fcntl.h>
;;
*) echo "Using $hint value $o_nonblock.";;
esac
-$rm -f try try.* .out core
+$rm_try
echo " "
echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
case "$eagain" in
'')
+ case "$d_fork:$d_pipe" in
+ define:define)
$cat head.c > try.c
$cat >>try.c <<EOCP
#include <errno.h>
#include <sys/types.h>
#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+#$i_fcntl I_FCNTL
+#ifdef I_FCNTL
+#include <fcntl.h>
+#endif
#define MY_O_NONBLOCK $o_nonblock
#ifndef errno /* XXX need better Configure test */
extern int errno;
#else
#include <strings.h>
#endif
-$signal_t blech(x) int x; { exit(3); }
+$signal_t blech(int x) { exit(3); }
EOCP
$cat >> try.c <<'EOCP'
int main()
ret = read(pd[0], buf, 1); /* Should read EOF */
alarm(0);
sprintf(string, "%d\n", ret);
- write(3, string, strlen(string));
+ write(4, string, strlen(string));
exit(0);
}
if eval $compile_ok; then
?X: Use script to avoid the possible 'alarm call' message
echo "$startsh" >mtry
- echo "$run ./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
+ echo "$run ./try >try.out 2>try.ret 4>try.err || exit 4" >>mtry
chmod +x mtry
./mtry >/dev/null 2>&1
case $? in
echo "I can't compile the test program--assuming errno EAGAIN will do."
eagain=EAGAIN
fi
+ ;;
+ *) echo "Can't figure out how to test this--assuming errno EAGAIN will do."
+ eagain=EAGAIN
+ val="$define"
+ ;;
+ esac
set d_eofnblk
eval $setvar
;;
esac
;;
esac
-$rm -f try try.* .out core head.c mtry
+$rm_try head.c mtry