[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fork() for microsoft windows (native but not Cygwin).
From: |
Tatsuro MATSUOKA |
Subject: |
Re: fork() for microsoft windows (native but not Cygwin). |
Date: |
Mon, 2 May 2016 11:12:38 +0900 (JST) |
----- Original Message -----
> From: Tatsuro MATSUOKA
> To: "octave-maintainers
> Cc:
> Date: 2016/5/2, Mon 04:26
> Subject: fork() for microsoft windows (native but not Cygwin).
>
> In the discussion for parallel octave-forge package:
> http://savannah.gnu.org/bugs/?41148
>
>
> It should be checked the implementation of fork() on windows.
> The native windows C compiler does not have a fork() function.
>
> On octave prompt
>
>>> help fork
>
> tells that fork() on octave implemented in libinterp/corefcn/syscalls.cc.
>
> I looked into the code of syscalls.cc.
> (http://octave.org/doxygen/4.1/d7/dba/syscalls_8cc_source.html)
>
> Around line 555,
>
> 555 DEFUNX ("fork", Ffork, args, ,
> 556 "-*- texinfo -*-\n\
> <snip>
> {
>
> 578 octave_value_list retval;
> 579
> 580 retval(1) = std::string ();
> 581 retval(0) = -1;
> 582
> 583 int nargin = args.length ();
> 584
> 585 if (nargin == 0)
> 586 {
> 587 std::string msg;
> 588
> 589 pid_t pid = octave_syscalls::fork (msg);
> 590
> 591 retval(1) = msg;
> 592 retval(0) = pid;
> 593 }
> 594 else
> 595 print_usage ();
> 596
> 597 return retval;
> 598 }
>
> In oct-syscalls.cc
> (http://octave.org/doxygen/4.0/d5/d5e/oct-syscalls_8cc_source.html)
> 107 pid_t
> 108 octave_syscalls::fork (std::string& msg)
> 109 {
> 110 pid_t status = -1;
> 111
> 112 #if defined (HAVE_FORK)
> 113 status = ::fork ();
> 114
> 115 if (status < 0)
> 116 msg = gnulib::strerror (errno);
> 117 #else
> 118 msg = NOT_SUPPORTED ("fork");
> 119 #endif
> 120
> 121 return status;
> 122 }
>
> To my knowledge, fork() is not implemented in native windows.
> Cygwin implements fork() because cygwin offers almost all posix APIs.
>
> The discussion resemble for pipe() on windows but native windows completely
> lacks the fork. If we want to use fork on windows we should implement
> it using windows API that perhaps in done on the Cygwin
As reported an another post, I have been succeeded to build octave-4.0.2
on native windows.
Thus I can check the config.log and config.h.
(Of course I can see config.h in include/octave-4.0.2/octave from binary
distribution.)
fork related parts of config.log
******************************************
configure:70184: checking for fork
configure:70184: gcc -o conftest.exe -g -O2 -pthread -fopenmp conftest.c -lm
-lgdi32 -lws2_32 -luser32 -lkernel32 -lgdi32 -lws2_32 -luser32 -lkernel32 >&5
conftest.c:594:6: warning: conflicting types for built-in function 'fork'
char fork ();
^
C:\Users\MATSUO~1\AppData\Local\Temp\ccQjF9mf.o: In function `main':
d:\usr\Tatsu\program\Octave\octaveBuild\4.0.2\build/conftest.c:605: undefined
reference to `fork'
collect2.exe: error: ld returned 1 exit status
configure:70184: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU Octave"
<snip a lot of define_s>
| #define HAVE_EXPM1F 1
| /* end confdefs.h. */
| /* Define fork to an innocuous variant, in case <limits.h> declares fork.
| For example, HP-UX 11i <limits.h> declares gettimeofday. */
| #define fork innocuous_fork
|
| /* System header to define __stub macros and hopefully few prototypes,
| which can conflict with char fork (); below.
| Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
| <limits.h> exists even on freestanding compilers. */
|
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|
| #undef fork
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char fork ();
| /* The GNU C library defines this for functions which it implements
| to always fail with ENOSYS. Some functions are actually named
| something starting with __ and the normal name is an alias. */
| #if defined __stub_fork || defined __stub___fork
| choke me
| #endif
|
| int
| main ()
| {
| return fork ();
| ;
| return 0;
| }
configure:70184: result: no
******************************************
fork related part of config.h
*******************************************
/* Define to 1 if you have the `fork' function. */
/* #undef HAVE_FORK */
*******************************************
Apparently the fork is not recognized and HAVE_FORK is undefined.
The expected behavior fork to print fork is not supported in the current
situation.
In think that this is a bug.
Is it better to register the phenomena to the bug tracker?
(I searched in the bug tracker by the keyword "fork" but cannot find topic that
related fork() to windows.)
Tatsuro