2015-10-21 Joseph Myers <joseph@codesourcery.com>
+ * io/tst-fcntl.c (fd): New static variable.
+ (do_prepare): Open temporary file here....
+ (do_test): ...not here.
+
* io/ftwtest-sh: Also trap on exit to remove temporary files.
2015-10-21 H.J. Lu <hongjiu.lu@intel.com>
/* Name of the temporary files. */
static char *name;
+/* File descriptor to temporary file. */
+static int fd;
+
void
do_prepare (int argc, char *argv[])
{
name = malloc (name_len + sizeof ("/fcntlXXXXXX"));
mempcpy (mempcpy (name, test_dir, name_len),
"/fcntlXXXXXX", sizeof ("/fcntlXXXXXX"));
+ /* Create the temporary file. */
+ fd = mkstemp (name);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ exit (1);
+ }
add_temp_file (name);
}
int
do_test (int argc, char *argv[])
{
- int fd;
int fd2;
int fd3;
struct stat64 st;
int val;
int result = 0;
- /* Create the temporary file. */
- fd = mkstemp (name);
- if (fd == -1)
- {
- printf ("cannot open temporary file: %m\n");
- return 1;
- }
if (fstat64 (fd, &st) != 0)
{
printf ("cannot stat test file: %m\n");