From 89648cf352fe7ab39715e2d242b77aca428aaac8 Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Wed, 15 Apr 2009 13:33:41 +0000 Subject: [PATCH] New macro STD_FD_VOID_SYSTEM_CALL to be used after system calls that create file descriptors but yield them in some way other than as their return values, such as pipe(2). Use this in OS_make_pipe so that the file exhaustion state is maintained correctly. --- v7/src/microcode/ux.h | 9 ++++++++- v7/src/microcode/uxio.c | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/v7/src/microcode/ux.h b/v7/src/microcode/ux.h index 62d3e2064..3673b02d7 100644 --- a/v7/src/microcode/ux.h +++ b/v7/src/microcode/ux.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ux.h,v 1.92 2009/04/15 13:09:20 riastradh Exp $ +$Id: ux.h,v 1.93 2009/04/15 13:33:40 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -880,4 +880,11 @@ extern bool UX_out_of_files_p; UX_out_of_files_p = false; \ } while (0) +#define STD_FD_VOID_SYSTEM_CALL(name, expression) \ + do { \ + while ((expression) < 0) \ + UX_prim_check_fd_errno (name); \ + UX_out_of_files_p = false; \ + } while (0) + #endif /* SCM_UX_H */ diff --git a/v7/src/microcode/uxio.c b/v7/src/microcode/uxio.c index 61de04d21..9d6739dbd 100644 --- a/v7/src/microcode/uxio.c +++ b/v7/src/microcode/uxio.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxio.c,v 1.64 2009/04/15 13:00:32 riastradh Exp $ +$Id: uxio.c,v 1.65 2009/04/15 13:33:41 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -333,8 +333,7 @@ OS_make_pipe (Tchannel * readerp, Tchannel * writerp) { int pv [2]; transaction_begin (); - while ((UX_pipe (pv)) < 0) - UX_prim_check_fd_errno (syscall_pipe); + STD_FD_VOID_SYSTEM_CALL (syscall_pipe, (UX_pipe (pv))); MAKE_CHANNEL ((pv[0]), channel_type_unix_pipe, (*readerp) =); OS_channel_close_on_abort (*readerp); MAKE_CHANNEL ((pv[1]), channel_type_unix_pipe, (*writerp) =); -- 2.25.1