annotate liboctave/wrappers/async-system-wrapper.c @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 7854d5752dd2
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 // Copyright (C) 2016-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
22264
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 // areadlink is provided by gnulib. We don't include gnulib headers
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 // directly in Octave's C++ source files to avoid problems that may be
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 // caused by the way that gnulib overrides standard library functions.
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #if defined (HAVE_CONFIG_H)
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 # include "config.h"
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #endif
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #if defined (__WIN32__) && ! defined (__CYGWIN__)
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 # include <stdlib.h>
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 # include <string.h>
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 # define WIN32_LEAN_AND_MEAN 1
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 # include <windows.h>
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #else
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 # include <sys/types.h>
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 # include <unistd.h>
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #endif
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include "async-system-wrapper.h"
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
29142
1024bc946c95 system: Support non-ASCII characters for asynchronous mode on Windows (bug #59572).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
46 #if defined (OCTAVE_USE_WINDOWS_API)
1024bc946c95 system: Support non-ASCII characters for asynchronous mode on Windows (bug #59572).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
47 # include "uniconv-wrappers.h"
1024bc946c95 system: Support non-ASCII characters for asynchronous mode on Windows (bug #59572).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
48 #endif
1024bc946c95 system: Support non-ASCII characters for asynchronous mode on Windows (bug #59572).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
49
22264
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 pid_t
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 octave_async_system_wrapper (const char *cmd)
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 {
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 int retval = -1;
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 if (! cmd)
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 return retval;
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 #if defined (OCTAVE_USE_WINDOWS_API)
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
29142
1024bc946c95 system: Support non-ASCII characters for asynchronous mode on Windows (bug #59572).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
60 STARTUPINFOW si;
22264
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 PROCESS_INFORMATION pi;
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 ZeroMemory (&si, sizeof (si));
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 ZeroMemory (&pi, sizeof (pi));
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
29142
1024bc946c95 system: Support non-ASCII characters for asynchronous mode on Windows (bug #59572).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
66 wchar_t *xcmd = u8_to_wchar (cmd);
22264
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
29142
1024bc946c95 system: Support non-ASCII characters for asynchronous mode on Windows (bug #59572).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
68 if (! CreateProcessW (NULL, xcmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
22264
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 retval = -1;
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 else
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 {
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 retval = pi.dwProcessId;
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 CloseHandle (pi.hProcess);
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 CloseHandle (pi.hThread);
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 }
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 free (xcmd);
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 #else
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 pid_t pid = fork ();
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 if (pid == 0)
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 execl (SHELL_PATH, "sh", "-c", cmd, (char *) (0));
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 else
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 retval = pid;
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 #endif
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 return retval;
9b78fda78300 fix build failure for --without-z (bug #48757)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 }