# HG changeset patch # User Bruno Haible # Date 1248122739 -7200 # Node ID 99b6167ab3d5af830d6365a339df506dfeaf59b7 # Parent 928845623bf5b9139b687ff2adf3d272062e639c Tweak for maintainability. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-07-20 Bruno Haible + + * tests/test-pipe.c (BACKUP_STDERR_FILENO): New macro. + (main): Use it. + 2009-07-20 Eric Blake test-pipe: make a bit more robust. diff --git a/tests/test-pipe.c b/tests/test-pipe.c --- a/tests/test-pipe.c +++ b/tests/test-pipe.c @@ -38,6 +38,7 @@ (outside the range of interesting fd's during the test) set up to duplicate the original stderr. */ +#define BACKUP_STDERR_FILENO 10 static FILE *myerr; #define ASSERT(expr) \ @@ -226,15 +227,16 @@ } if (strcmp (argv[1], "child") == 0) { - /* fd 2 might be closed, but fd 10 is the original stderr. */ - myerr = fdopen (10, "w"); + /* fd 2 might be closed, but fd BACKUP_STDERR_FILENO is the original + stderr. */ + myerr = fdopen (BACKUP_STDERR_FILENO, "w"); if (!myerr) return 2; return child_main (argc, argv); } /* We might close fd 2 later, so save it in fd 10. */ - if (dup2 (STDERR_FILENO, 10) != 10 - || (myerr = fdopen (10, "w")) == NULL) + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) return 2; return parent_main (argc, argv); }