re PR libfortran/89020 (close(status='DELETE') does not remove file)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 26 Jan 2019 20:27:16 +0000 (20:27 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 26 Jan 2019 20:27:16 +0000 (20:27 +0000)
2019-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR libfortran/88020
* io/close.c (st_close): Generate error if calls to 'remove' return
an error.

From-SVN: r268301

libgfortran/ChangeLog
libgfortran/io/close.c

index 1cb8961d1ad8c502717356ceb94cd10b0f9636a6..adacd8adcac3ee41c98840d61b3b378de0039bb7 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libfortran/88020
+       * io/close.c (st_close): Generate error if calls to 'remove' return
+       an error.
+
 2019-01-17  Andrew Stubbs  <ams@codesourcery.com>
            Kwok Cheung Yeung  <kcy@codesourcery.com>
            Julian Brown  <julian@codesourcery.com>
index cbcbf4e71a13c29ec653361c59f78d0858c9b3e0..2b35e49c9ccd408fbc80ca5717f30d22301e8f98 100644 (file)
@@ -99,7 +99,11 @@ st_close (st_parameter_close *clp)
              else
                {
 #if HAVE_UNLINK_OPEN_FILE
-                 remove (u->filename);
+
+                 if (remove (u->filename))
+                   generate_error (&clp->common, LIBERROR_OS,
+                           "File cannot be deleted, possibly in use by"
+                           " another process");
 #else
                  path = strdup (u->filename);
 #endif
@@ -112,7 +116,10 @@ st_close (st_parameter_close *clp)
 #if !HAVE_UNLINK_OPEN_FILE
       if (path != NULL)
        {
-         remove (path);
+         if (remove (u->filename))
+           generate_error (&clp->common, LIBERROR_OS,
+                   "File cannot be deleted, possibly in use by"
+                   " another process");
          free (path);
        }
 #endif