This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran, patch] Implement EXECUTE_COMMAND_LINE


On 08/29/2010 11:13 PM, FX wrote:
This is a respin of my patch last year (http://gcc.gnu.org/ml/fortran/2009-05/msg00044.html), with some more testing, a testcase and documentation.

Bootstrapped and regtesting on x86_64-darwin, OK to commit?

Please add a @ref to SYSTEM, pointing to the new intrinsic; maybe one should also recommend there to use the F2008 intrinsics (similarly to GETARG/IARGC).


+The @code{COMMAND} argument is passed to the shell and executed, using
+the @code{system()} call.  (The shell is @code{sh} on Unix systems, and


I wonder whether one should add a qualifier before "system", e.g. "the POSIX's system call" or the C library's system call" to make clear that it is not Fortran's SYSTEM call.



+ char cmd[command_len + 1];


Welcome in the world of C99's VLA :-)


+execute_command_line (const char *command, bool wait, int *exitstat,



Using 'bool wait' instead of "bool *wait" looks wrong. I think you need either use "*bool" or something like
set_attr_value (5, false, true, false, false, false);
(or shorter: set_attr_value (2, false, true))


+#if defined(HAVE_FORK)
+  if (!wait)
+      *cmdstat = 0;
+      if ((pid = fork())<  0)
+	*cmdstat = EXEC_SYSTEMFAILED;


That won't work if cmdstat is not available. As F2008 states:


"If a condition occurs that would assign a nonzero value to CMDSTAT but the CMDSTAT variable is not present, error termination is initiated."

+      /* Synchronous execution.  */
+      int res = system (cmd);
+
+      if (!wait)
+	*cmdstat = -2;


Ditto for the cmdstat/exitstat. Additionally, I read the standard such that the intrinsic immediately returns with cmdstat = -2 if HAVE_FORK is false - not after the synchronous execution. However, I think the standard is not unambiguous.



Tobias



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]