annotate libinterp/corefcn/syscalls.cc @ 33623:4517f929c59d bytecode-interpreter tip

maint: Merge default to bytecode-interpreter
author Arun Giridhar <arungiridhar@gmail.com>
date Fri, 24 May 2024 16:22:41 -0400
parents 5fded8395daa
children
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 //
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
3 // Copyright (C) 1996-2024 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 ////////////////////////////////////////////////////////////////////////
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
25
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
26 // Thomas Baier <baier@ci.tuwien.ac.at> added the original versions of
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
27 // the following functions:
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
28 //
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
29 // mkfifo unlink waitpid
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
30
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21672
diff changeset
31 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
32 # include "config.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
33 #endif
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
34
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
35 #include <cstdio>
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
36 #include <cstring>
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
37
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
38 #include "cmd-hist.h"
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
39 #include "fcntl-wrappers.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
40 #include "file-ops.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
41 #include "file-stat.h"
22087
7f79c716876c eliminate unused parameter from octave::sys::popen2
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
42 #include "lo-utils.h"
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
43 #include "oct-env.h"
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
44 #include "oct-syscalls.h"
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
45 #include "oct-uname.h"
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
46
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
47 #include "defun.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
48 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21055
diff changeset
49 #include "errwarn.h"
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
50 #include "event-manager.h"
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
51 #include "input.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
52 #include "interpreter.h"
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
53 #include "oct-hist.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
54 #include "oct-map.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
55 #include "oct-stdstrm.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
56 #include "oct-stream.h"
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
57 #include "ovl.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
58 #include "sysdep.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
59 #include "utils.h"
2366
c90105b99479 [project @ 1996-10-11 23:22:27 by jwe]
jwe
parents: 2305
diff changeset
60 #include "variables.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
61
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31187
diff changeset
62 OCTAVE_BEGIN_NAMESPACE(octave)
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
63
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
64 static octave_scalar_map
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
65 mk_stat_map (const sys::base_file_stat& fs)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
66 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
67 static bool have_rdev
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
68 = sys::base_file_stat::have_struct_stat_st_rdev ();
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
69 static bool have_blksize
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
70 = sys::base_file_stat::have_struct_stat_st_blksize ();
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
71 static bool have_blocks
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
72 = sys::base_file_stat::have_struct_stat_st_blocks ();
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
73
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
74 static double nan = numeric_limits<double>::NaN ();
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
75
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
76 octave_scalar_map m;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
77
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
78 m.assign ("dev", static_cast<double> (fs.dev ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
79 m.assign ("ino", fs.ino ());
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
80 m.assign ("mode", fs.mode ());
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
81 m.assign ("modestr", fs.mode_as_string ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
82 m.assign ("nlink", fs.nlink ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
83 m.assign ("uid", fs.uid ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
84 m.assign ("gid", fs.gid ());
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
85 m.assign ("rdev", have_rdev ? static_cast<double> (fs.rdev ()) : nan);
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
86 m.assign ("size", fs.size ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
87 m.assign ("atime", fs.atime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
88 m.assign ("mtime", fs.mtime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
89 m.assign ("ctime", fs.ctime ());
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
90
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
91 if (have_blksize)
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
92 m.assign ("blksize", fs.blksize ());
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
93 else
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
94 m.assign ("blksize", nan);
21937
55f7de37b618 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21935
diff changeset
95
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
96 if (have_blocks)
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
97 m.assign ("blocks", fs.blocks ());
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
98 else
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
99 m.assign ("blocks", nan);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
100
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
101 return m;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
102 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
103
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
104 static octave_value_list
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
105 mk_stat_result (const sys::base_file_stat& fs)
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
106 {
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
107 if (fs)
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
108 return ovl (octave_value (mk_stat_map (fs)), 0, "");
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
109 else
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
110 return ovl (Matrix (), -1, fs.error ());
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
111 }
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
112
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
113 DEFMETHODX ("dup2", Fdup2, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
114 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
115 @deftypefn {} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
116 Duplicate a file descriptor.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
117
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
118 If successful, @var{fid} is greater than zero and contains the new file ID@.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
119 Otherwise, @var{fid} is negative and @var{msg} contains a system-dependent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
120 error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
121 @seealso{fopen, fclose, fcntl}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
122 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
123 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20800
diff changeset
124 if (args.length () != 2)
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
125 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
126
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
127 int i_old, i_new;
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
128 try
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
129 {
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
130 // Look up FID in Octave's list of open streams.
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
131 stream_list& streams = interp.get_stream_list ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
132
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
133 stream old_stream = streams.lookup (args(0), "dup2");
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
134 stream new_stream = streams.lookup (args(1), "dup2");
33233
a0ea07a4c043 allow dup2, fcntl, and stat to work for files not known to Octave (bug #65393)
John W. Eaton <jwe@octave.org>
parents: 33054
diff changeset
135
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
136 i_old = old_stream.file_number ();
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
137 i_new = new_stream.file_number ();
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
138 }
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
139 catch (execution_exception& ee)
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
140 {
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
141 // If the FIDs are not known to Octave, try the provided FIDs directly.
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
142 i_old = args(0).int_value (true);
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
143 i_new = args(1).int_value (true);
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
144 }
3341
14cfc9475fe4 [project @ 1999-11-05 08:11:58 by jwe]
jwe
parents: 3340
diff changeset
145
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
146 if (i_old < 0 || i_new < 0)
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
147 // Bad FIDs, return error immediately
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
148 return ovl (-1, "");
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
149
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
150 std::string msg;
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
151
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
152 int status = sys::dup2 (i_old, i_new, msg);
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
153
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
154 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
155 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
156
25994
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
157 DEFMETHODX ("exec", Fexec, interp, args, ,
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
158 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
159 @deftypefn {} {[@var{err}, @var{msg}] =} exec (@var{file}, @var{args})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
160 Replace current process with a new process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
161
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
162 Calling @code{exec} without first calling @code{fork} will terminate your
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
163 current Octave process and replace it with the program named by @var{file}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
164 For example,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
165
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
166 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
167 exec ("ls", "-l")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
168 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
169
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
170 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
171 will run @code{ls} and return you to your shell prompt.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
172
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
173 If successful, @code{exec} does not return. If @code{exec} does return,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
174 @var{err} will be nonzero, and @var{msg} will contain a system-dependent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
175 error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
176 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
177 {
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
178 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
179
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
180 if (nargin < 1 || nargin > 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
181 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
182
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
183 std::string exec_file = args(0).xstring_value ("exec: FILE must be a string");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
184
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
185 string_vector exec_args;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
186
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
187 if (nargin == 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
188 {
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20956
diff changeset
189 string_vector tmp = args(1).xstring_vector_value ("exec: all arguments must be strings");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
190
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
191 int len = tmp.numel ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
192
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
193 exec_args.resize (len + 1);
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
194
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
195 exec_args[0] = exec_file;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
196
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
197 for (int i = 0; i < len; i++)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
198 exec_args[i+1] = tmp[i];
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
199 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
200 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
201 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
202 exec_args.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
203
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
204 exec_args[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
205 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
206
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
207 history_system& history_sys = interp.get_history_system ();
25994
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
208
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
209 history_sys.write_timestamp ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
210
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
211 if (! command_history::ignoring_entries ())
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
212 command_history::clean_up_and_save ();
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
213
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
214 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
215
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
216 int status = sys::execvp (exec_file, exec_args, msg);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
217
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
218 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
219 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
220
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
221 DEFMETHODX ("popen2", Fpopen2, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
222 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
223 @deftypefn {} {[@var{in}, @var{out}, @var{pid}] =} popen2 (@var{command}, @var{args})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
224 Start a subprocess with two-way communication.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
225
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
226 The name of the process is given by @var{command}, and @var{args} is an
22713
9e415e57a6a7 doc: Clarify docstring for popen2 (bug #49524).
Rik <rik@octave.org>
parents: 22407
diff changeset
227 array or cell array of strings containing options for the command.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
228
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
229 The file identifiers for the input and output streams of the subprocess are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
230 returned in @var{in} and @var{out}. If execution of the command is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
231 successful, @var{pid} contains the process ID of the subprocess. Otherwise,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
232 @var{pid} is @minus{}1.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
233
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
234 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
235
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
236 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
237 [in, out, pid] = popen2 ("sort", "-r");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
238 fputs (in, "these\nare\nsome\nstrings\n");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
239 fclose (in);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
240 EAGAIN = errno ("EAGAIN");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
241 done = false;
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
242 do
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
243 s = fgets (out);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
244 if (ischar (s))
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
245 fputs (stdout, s);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
246 elseif (errno () == EAGAIN)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
247 pause (0.1);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
248 fclear (out);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
249 else
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
250 done = true;
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
251 endif
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
252 until (done)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
253 fclose (out);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
254 waitpid (pid);
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
255
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
256 @print{} these
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
257 @print{} strings
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
258 @print{} some
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
259 @print{} are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
260 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
261
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
262 Note that @code{popen2}, unlike @code{popen}, will not @nospell{"reap"}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
263 the child process. If you don't use @code{waitpid} to check the child's
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
264 exit status, it will linger until Octave exits.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
265 @seealso{popen, waitpid}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
266 @end deftypefn */)
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
267 {
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
268 int nargin = args.length ();
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
269
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
270 if (nargin < 1 || nargin > 3)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
271 print_usage ();
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
272
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
273 std::string exec_file = args(0).xstring_value ("popen2: COMMAND argument must be a string");
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
274
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
275 string_vector arg_list;
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
276
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
277 if (nargin >= 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
278 {
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20956
diff changeset
279 string_vector tmp = args(1).xstring_vector_value ("popen2: all arguments must be strings");
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
280
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
281 int len = tmp.numel ();
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
282
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
283 arg_list.resize (len + 1);
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
284
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
285 arg_list[0] = exec_file;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
286
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
287 for (int i = 0; i < len; i++)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
288 arg_list[i+1] = tmp[i];
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
289 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
290 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
291 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
292 arg_list.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
293
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
294 arg_list[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
295 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
296
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
297 bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
298
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
299 int filedesc[2];
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
300 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
301 pid_t pid;
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
302
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
303 pid = sys::popen2 (exec_file, arg_list, sync_mode, filedesc, msg);
22087
7f79c716876c eliminate unused parameter from octave::sys::popen2
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
304
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
305 if (pid < 0)
26149
242aa7b2c783 Silence unnecessary warnings about security-format (bug #55046).
Rik <rik@octave.org>
parents: 25994
diff changeset
306 error ("%s", msg.c_str ());
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
307
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
308 FILE *ifile = fdopen (filedesc[1], "r");
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
309 FILE *ofile = fdopen (filedesc[0], "w");
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
310
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
311 stream is = stdiostream::create (exec_file + "-in", ifile, std::ios::in);
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
312
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
313 stream os = stdiostream::create (exec_file + "-out", ofile, std::ios::out);
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
314
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
315 stream_list& streams = interp.get_stream_list ();
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
316
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
317 return ovl (streams.insert (os), streams.insert (is), pid);
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
318 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
319
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
320 /*
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
321
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
322 %!test # UNIX-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
323 %! if (isunix () || ismac ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
324 %! [in, out, pid] = popen2 ("sort", "-r");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
325 %! EAGAIN = errno ("EAGAIN");
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
326 %! fputs (in, "these\nare\nsome\nstrings\n");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
327 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
328 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
329 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
330 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
331 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
332 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
333 %! if (ismac ()) # FIXME: Is this necessary?
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
334 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
335 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
336 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
337 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
338 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
339 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
340 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
341 %! fclear (out);
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20898
diff changeset
342 %! pause (0.1);
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
343 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
344 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
345 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
346 %! else
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
347 %! done = true;
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
348 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
349 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
350 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
351 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
352 %! assert (str, {"these\n","strings\n","some\n","are\n"});
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
353 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
354
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
355 %!test # Windows-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
356 %! if (ispc () && ! isunix ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
357 %! [in, out, pid] = popen2 ('C:\Windows\system32\sort.exe', "/R");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
358 %! EAGAIN = errno ("EINVAL");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
359 %! fputs (in, "these\r\nare\r\nsome\r\nstrings\r\n");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
360 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
361 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
362 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
363 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
364 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
365 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
366 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
367 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
368 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
369 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
370 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
371 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
372 %! fclear (out);
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20898
diff changeset
373 %! pause (0.1);
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
374 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
375 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
376 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
377 %! else
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
378 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
379 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
380 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
381 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
382 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
383 %! assert (str, {"these\r\n","strings\r\n","some\r\n","are\r\n"});
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
384 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
385
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
386 */
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
387
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
388 DEFMETHODX ("fcntl", Ffcntl, interp, args, nargout,
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
389 doc: /* -*- texinfo -*-
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
390 @deftypefn {} {} fcntl (@var{fid}, @var{request}, @var{arg})
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
391 @deftypefnx {} {[@var{status}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
392 Change the properties of the open file @var{fid}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
393
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
394 The following values may be passed as @var{request}:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
395
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
396 @vtable @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
397 @item F_DUPFD
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
398 Return a duplicate file descriptor.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
399
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
400 @item F_GETFD
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
401 Return the file descriptor flags for @var{fid}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
402
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
403 @item F_SETFD
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
404 Set the file descriptor flags for @var{fid}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
405
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
406 @item F_GETFL
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
407 Return the file status flags for @var{fid}. The following codes may be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
408 returned (some of the flags may be undefined on some systems).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
409
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
410 @vtable @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
411 @item O_RDONLY
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
412 Open for reading only.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
413
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
414 @item O_WRONLY
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
415 Open for writing only.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
416
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
417 @item O_RDWR
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
418 Open for reading and writing.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
419
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
420 @item O_APPEND
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
421 Append on each write.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
422
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
423 @item O_CREAT
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
424 Create the file if it does not exist.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
425
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
426 @item O_NONBLOCK
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
427 Non-blocking mode.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
428
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
429 @item O_SYNC
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
430 Wait for writes to complete.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
431
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
432 @item O_ASYNC
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
433 Asynchronous I/O.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
434 @end vtable
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
435
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
436 @item F_SETFL
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
437 Set the file status flags for @var{fid} to the value specified by @var{arg}.
33054
1a6cb4552775 doc: Force Texinfo to render a space after @w{} macro.
Rik <rik@octave.org>
parents: 32632
diff changeset
438 The only flags that can be changed are @w{@code{O_APPEND}}@ and
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
439 @w{@code{O_NONBLOCK}}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
440 @end vtable
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
441
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
442 If successful, @var{status} is 0 and @var{msg} is an empty string. Otherwise,
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
443 @var{status} is -1 and @var{msg} contains a system-dependent error
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
444 message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
445 @seealso{fopen, dup2}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
446 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
447 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
448 if (args.length () != 3)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
449 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
450
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
451 int fid;
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
452 try
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
453 {
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
454 // Look up FID in Octave's list of open streams.
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
455 stream_list& streams = interp.get_stream_list ();
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
456 stream strm = streams.lookup (args(0), "fcntl");
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
457 fid = strm.file_number ();
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
458 }
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
459 catch (execution_exception& ee)
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
460 {
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
461 // If the file is not known to Octave, try the provided file ID directly.
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
462 fid = args(0).int_value (true);
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
463 }
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
464
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
465 if (fid < 0)
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
466 error ("fcntl: invalid file id FID");
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
467
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
468 int req = args(1).strict_int_value ("fcntl: REQUEST must be an integer");
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
469 int arg = args(2).strict_int_value ("fcntl: ARG must be an integer");
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
470
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
471 octave_value_list retval;
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
472 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
473
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
474 int status = sys::fcntl (fid, req, arg, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
475
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
476 if (nargout == 0)
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
477 {
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
478 if (status < 0)
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
479 error ("fcntl: operation failed: %s", msg.c_str ());
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
480 }
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
481 else
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
482 {
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
483 if (status < 0)
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
484 retval = ovl (-1.0, msg);
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
485 else
33238
ddd3da3f1a70 Return flags from fcntl (bug #65504)
Rik <rik@octave.org>
parents: 33234
diff changeset
486 retval = ovl (status, "");
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
487 }
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
488
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
489 return retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
490 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
491
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
492 DEFMETHODX ("fork", Ffork, interp, args, ,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
493 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
494 @deftypefn {} {[@var{pid}, @var{msg}] =} fork ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
495 Create a copy of the current process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
496
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
497 Fork can return one of the following values:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
498
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
499 @table @asis
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
500 @item > 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
501 You are in the parent process. The value returned from @code{fork} is the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
502 process id of the child process. You should probably arrange to wait for
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
503 any child processes to exit.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
504
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
505 @item 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
506 You are in the child process. You can call @code{exec} to start another
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
507 process. If that fails, you should probably call @code{exit}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
508
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
509 @item < 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
510 The call to @code{fork} failed for some reason. You must take evasive
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
511 action. A system dependent error message will be waiting in @var{msg}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
512 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
513 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
514 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
515 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
516 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
517
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
518 if (interp.at_top_level ())
21604
d7a268e68e69 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21547
diff changeset
519 error ("fork: cannot be called from command line");
21343
980abb267014 Emit error if fork called directly from command line.
Rik <rik@octave.org>
parents: 21301
diff changeset
520
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
521 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
522
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
523 pid_t pid = sys::fork (msg);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
524
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
525 return ovl (pid, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
526 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
527
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
528 DEFUNX ("getpgrp", Fgetpgrp, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
529 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
530 @deftypefn {} {pgid =} getpgrp ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
531 Return the process group id of the current process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
532 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
533 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
534 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
535 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
536
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
537 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
538
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
539 pid_t pid = sys::getpgrp (msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
540
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
541 return ovl (pid, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
542 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
543
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
544 DEFUNX ("getpid", Fgetpid, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
545 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
546 @deftypefn {} {pid =} getpid ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
547 Return the process id of the current process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
548 @seealso{getppid}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
549 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
550 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
551 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
552 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
553
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
554 return ovl (sys::getpid ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
555 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
556
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
557 DEFUNX ("getppid", Fgetppid, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
558 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
559 @deftypefn {} {pid =} getppid ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
560 Return the process id of the parent process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
561 @seealso{getpid}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
562 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
563 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
564 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
565 print_usage ();
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
566
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
567 return ovl (sys::getppid ());
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
568 }
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
569
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
570 DEFUNX ("getegid", Fgetegid, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
571 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
572 @deftypefn {} {egid =} getegid ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
573 Return the effective group id of the current process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
574 @seealso{getgid}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
575 @end deftypefn */)
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
576 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
577 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
578 print_usage ();
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
579
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
580 return ovl (sys::getegid ());
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
581 }
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
582
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
583 DEFUNX ("getgid", Fgetgid, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
584 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
585 @deftypefn {} {gid =} getgid ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
586 Return the real group id of the current process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
587 @seealso{getegid}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
588 @end deftypefn */)
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
589 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
590 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
591 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
592
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
593 return ovl (sys::getgid ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
594 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
595
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
596 DEFUNX ("geteuid", Fgeteuid, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
597 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
598 @deftypefn {} {euid =} geteuid ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
599 Return the effective user id of the current process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
600 @seealso{getuid}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
601 @end deftypefn */)
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
602 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
603 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
604 print_usage ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
605
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
606 return ovl (sys::geteuid ());
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
607 }
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
608
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
609 DEFUNX ("getuid", Fgetuid, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
610 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
611 @deftypefn {} {uid =} getuid ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
612 Return the real user id of the current process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
613 @seealso{geteuid}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
614 @end deftypefn */)
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
615 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
616 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
617 print_usage ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
618
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
619 return ovl (sys::getuid ());
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
620 }
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
621
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
622 DEFUNX ("kill", Fkill, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
623 doc: /* -*- texinfo -*-
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
624 @deftypefn {} {} kill (@var{pid}, @var{sig})
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
625 @deftypefnx {} {[@var{status}, @var{msg}] =} kill (@var{pid}, @var{sig})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
626 Send signal @var{sig} to process @var{pid}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
627
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
628 If @var{pid} is positive, then signal @var{sig} is sent to @var{pid}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
629
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
630 If @var{pid} is 0, then signal @var{sig} is sent to every process in the
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
631 process group of the current process.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
632
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
633 If @var{pid} is -1, then signal @var{sig} is sent to every process except
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
634 process 1.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
635
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
636 If @var{pid} is less than -1, then signal @var{sig} is sent to every process in
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
637 the process group @var{-pid}.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
638
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
639 If @var{sig} is 0, then no signal is sent, but error checking is still
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
640 performed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
641
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
642 If successful, @var{status} is 0 and @var{msg} is an empty string.
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
643 Otherwise, @var{status} is -1 and @var{msg} contains a system-dependent
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
644 error message.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
645 @end deftypefn */)
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
646 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
647 if (args.length () != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
648 print_usage ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
649
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
650 pid_t pid = args(0).int_value (true);
20560
56fee8f84fe7 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
651
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
652 int sig = args(1).int_value (true);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
653
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
654 octave_value_list retval;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
655 std::string msg;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
656
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
657 int status = sys::kill (pid, sig, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
658
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
659 if (nargout == 0)
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
660 {
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
661 if (status < 0)
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
662 error ("kill: operation failed: %s", msg.c_str ());
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
663 }
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
664 else
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
665 {
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
666 if (status < 0)
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
667 retval = ovl (-1.0, msg);
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
668 else
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
669 retval = ovl (0.0, "");
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
670 }
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
671
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
672 return retval;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
673 }
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
674
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
675 DEFUNX ("lstat", Flstat, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
676 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
677 @deftypefn {} {@var{info} =} lstat (@var{symlink})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
678 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
679 Return a structure @var{info} containing information about the symbolic link
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
680 @var{symlink}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
681
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
682 The function outputs are described in the documentation for @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
683 @seealso{stat, symlink}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
684 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
685 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
686 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
687 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
688
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
689 std::string fname = args(0).xstring_value ("lstat: NAME must be a string");
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
690
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
691 sys::file_stat fs (fname, false);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
692
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
693 return mk_stat_result (fs);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
694 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
695
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
696 // FIXME: This routine also exists verbatim in file-io.cc.
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
697 // Maybe change to be a general utility routine.
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
698 static int
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
699 convert (int x, int ibase, int obase)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
700 {
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
701 int retval = 0;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
702
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
703 int tmp = x % obase;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
704
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
705 if (tmp > ibase - 1)
20428
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20232
diff changeset
706 error ("mkfifo: invalid digit");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
707
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
708 retval = tmp;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
709 int mult = ibase;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
710 while ((x = (x - tmp) / obase))
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
711 {
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
712 tmp = x % obase;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
713
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
714 if (tmp > ibase - 1)
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
715 error ("mkfifo: invalid digit");
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
716
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
717 retval += mult * tmp;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
718 mult *= ibase;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
719 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
720
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
721 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
722 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
723
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
724 DEFUNX ("mkfifo", Fmkfifo, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
725 doc: /* -*- texinfo -*-
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
726 @deftypefn {} {} mkfifo (@var{name}, @var{mode})
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
727 @deftypefnx {} {[@var{status}, @var{msg}] =} mkfifo (@var{name}, @var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
728 Create a FIFO special file named @var{name} with file mode @var{mode}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
729
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
730 @var{mode} is interpreted as an octal number and is subject to umask
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
731 processing. The final calculated mode is @code{@var{mode} - @var{umask}}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
732
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
733 If successful, @var{status} is 0 and @var{msg} is an empty string.
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
734 Otherwise, @var{status} is -1 and @var{msg} contains a system-dependent
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
735 error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
736 @seealso{pipe, umask}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
737 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
738 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
739 if (args.length () != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
740 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
741
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
742 std::string name = args(0).xstring_value ("mkfifo: FILE must be a string");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
743
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
744 int octal_mode = args(1).strict_int_value ("mkfifo: MODE must be an integer");
4254
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4233
diff changeset
745
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
746 if (octal_mode < 0)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
747 error ("mkfifo: MODE must be a positive integer value");
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
748
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
749 int mode = convert (octal_mode, 8, 10);
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
750
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
751 octave_value_list retval;
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
752 std::string msg;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
753
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
754 int status = sys::mkfifo (name, mode, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
755
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
756 if (nargout == 0)
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
757 {
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
758 if (status < 0)
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
759 error ("mkfifo: operation failed: %s", msg.c_str ());
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
760 }
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
761 else
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
762 {
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
763 if (status < 0)
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
764 retval = ovl (-1.0, msg);
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
765 else
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
766 retval = ovl (0.0, "");
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
767 }
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
768
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
769 return retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
770 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
771
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
772 /*
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
773
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
774 ## Test input validation
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
775 %!error mkfifo ()
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
776 %!error mkfifo ("abc")
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
777 %!error mkfifo ("abc", 777, 123)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
778 %!error <FILE must be a string> mkfifo (123, 456)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
779 ## FIXME: These tests should work, but lasterr is not being set correctly.
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
780 #%!error <MODE must be an integer> mkfifo ("abc", {456})
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
781 #%!error <MODE must be a positive integer value> mkfifo ("abc", -1)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
782
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
783 */
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
784
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
785 DEFMETHODX ("pipe", Fpipe, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
786 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
787 @deftypefn {} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
788 Create a pipe and return the reading and writing ends of the pipe into
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
789 @var{read_fd} and @var{write_fd} respectively.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
790
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
791 If successful, @var{err} is 0 and @var{msg} is an empty string.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
792 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
793 error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
794 @seealso{mkfifo}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
795 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
796 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
797 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
798 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
799
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
800 int fid[2];
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
801 std::string msg;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
802
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
803 int status = sys::pipe (fid, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
804
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
805 if (status < 0)
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
806 return ovl (-1, -1, -1, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
807 else
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
808 {
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
809 FILE *ifile = fdopen (fid[0], "r");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
810 FILE *ofile = fdopen (fid[1], "w");
4327
c29c382a5b4b [project @ 2003-02-16 03:24:26 by jwe]
jwe
parents: 4294
diff changeset
811
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
812 stream is = stdiostream::create ("pipe-in", ifile, std::ios::in);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
813
29991
3988112c7116 move i/o stream classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
814 stream os = stdiostream::create ("pipe-out", ofile, std::ios::out);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
815
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
816 stream_list& streams = interp.get_stream_list ();
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
817
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
818 return ovl (streams.insert (is), streams.insert (os), status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
819 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
820 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
821
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
822 DEFMETHODX ("stat", Fstat, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
823 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
824 @deftypefn {} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{file})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
825 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{fid})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
826 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{file})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
827 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{fid})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
828 Return a structure @var{info} containing the following information about
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
829 @var{file} or file identifier @var{fid}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
830
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
831 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
832 @item dev
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
833 ID of device containing a directory entry for this file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
834
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
835 @item ino
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
836 File number of the file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
837
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
838 @item mode
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
839 File mode, as an integer. Use the functions @w{@code{S_ISREG}},
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
840 @w{@code{S_ISDIR}}, @w{@code{S_ISCHR}}, @w{@code{S_ISBLK}},
33054
1a6cb4552775 doc: Force Texinfo to render a space after @w{} macro.
Rik <rik@octave.org>
parents: 32632
diff changeset
841 @w{@code{S_ISFIFO}}, @w{@code{S_ISLNK}}, or @w{@code{S_ISSOCK}}@ to extract
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
842 information from this value.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
843
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
844 @item modestr
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
845 File mode, as a string of ten letters or dashes as would be returned by
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
846 @kbd{ls -l}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
847
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
848 @item nlink
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
849 Number of links.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
850
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
851 @item uid
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
852 User ID of file's owner.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
853
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
854 @item gid
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
855 Group ID of file's group.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
856
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
857 @item rdev
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
858 ID of device for block or character special files.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
859
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
860 @item size
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
861 Size in bytes.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
862
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
863 @item atime
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
864 Time of last access in the same form as time values returned from
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
865 @code{time}. @xref{Timing Utilities}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
866
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
867 @item mtime
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
868 Time of last modification in the same form as time values returned from
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
869 @code{time}. @xref{Timing Utilities}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
870
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
871 @item ctime
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
872 Time of last file status change in the same form as time values
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
873 returned from @code{time}. @xref{Timing Utilities}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
874
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
875 @item blksize
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
876 Size of blocks in the file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
877
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
878 @item blocks
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
879 Number of blocks allocated for file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
880 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
881
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
882 If the call is successful @var{err} is 0 and @var{msg} is an empty string.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
883 If the file does not exist, or some other error occurs, @var{info} is an
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
884 empty matrix, @var{err} is @minus{}1, and @var{msg} contains the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
885 corresponding system error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
886
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
887 If @var{file} is a symbolic link, @code{stat} will return information about
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
888 the actual file that is referenced by the link. Use @code{lstat} if you
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
889 want information about the symbolic link itself.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
890
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
891 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
892
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
893 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
894 [info, err, msg] = stat ("/vmlinuz")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
895 @result{} info =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
896 @{
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
897 atime = 855399756
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
898 rdev = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
899 ctime = 847219094
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
900 uid = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
901 size = 389218
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
902 blksize = 4096
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
903 mtime = 847219094
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
904 gid = 6
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
905 nlink = 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
906 blocks = 768
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
907 mode = -rw-r--r--
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
908 modestr = -rw-r--r--
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
909 ino = 9316
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
910 dev = 2049
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
911 @}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
912 @result{} err = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
913 @result{} msg =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
914 @end example
25782
0862570da0ae isfile.m: New function for Matlab compatibility (bug #54508).
Rik <rik@octave.org>
parents: 25781
diff changeset
915 @seealso{lstat, ls, dir, isfile, isfolder}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
916 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
917 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
918 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
919 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
920
2262
1300df4a33d6 [project @ 1996-05-23 06:49:32 by jwe]
jwe
parents: 2086
diff changeset
921 octave_value_list retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
922
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
923 if (args(0).is_scalar_type ())
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
924 {
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
925 int fid;
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
926 try
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
927 {
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
928 // Look up FID in Octave's list of open streams.
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
929 stream_list& streams = interp.get_stream_list ();
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
930 fid = streams.get_file_number (args(0));
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
931 }
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
932 catch (execution_exception& ee)
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
933 {
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
934 // If the file is not known to Octave, try provided file ID directly.
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
935 fid = args(0).int_value (true);
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
936 }
33233
a0ea07a4c043 allow dup2, fcntl, and stat to work for files not known to Octave (bug #65393)
John W. Eaton <jwe@octave.org>
parents: 33054
diff changeset
937
a0ea07a4c043 allow dup2, fcntl, and stat to work for files not known to Octave (bug #65393)
John W. Eaton <jwe@octave.org>
parents: 33054
diff changeset
938 if (fid < 0)
33234
e104e9f0cf62 allow dup2, fcntl, and stat to work for file IDs not tracked by Octave (bug #65393)
Rik <rik@octave.org>
parents: 33233
diff changeset
939 error ("stat: invalid file id FID");
33233
a0ea07a4c043 allow dup2, fcntl, and stat to work for files not known to Octave (bug #65393)
John W. Eaton <jwe@octave.org>
parents: 33054
diff changeset
940
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
941 sys::file_fstat fs (fid);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
942
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
943 retval = mk_stat_result (fs);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
944 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
945 else
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
946 {
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
947 std::string fname = args(0).xstring_value ("stat: NAME must be a string");
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
948
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
949 sys::file_stat fs (fname);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
950
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
951 retval = mk_stat_result (fs);
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
952 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
953
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
954 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
955 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
956
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
957 DEFUNX ("S_ISREG", FS_ISREG, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
958 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
959 @deftypefn {} {@var{tf} =} S_ISREG (@var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
960 Return true if @var{mode} corresponds to a regular file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
961
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
962 The value of @var{mode} is assumed to be returned from a call to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
963 @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
964 @seealso{stat, lstat}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
965 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
966 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
967 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
968 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
969
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
970 double mode = args(0).xdouble_value ("S_ISREG: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
971
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
972 return ovl (sys::file_stat::is_reg (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
973 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
974
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
975 DEFUNX ("S_ISDIR", FS_ISDIR, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
976 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
977 @deftypefn {} {@var{tf} =} S_ISDIR (@var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
978 Return true if @var{mode} corresponds to a directory.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
979
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
980 The value of @var{mode} is assumed to be returned from a call to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
981 @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
982 @seealso{stat, lstat}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
983 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
984 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
985 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
986 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
987
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
988 double mode = args(0).xdouble_value ("S_ISDIR: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
989
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
990 return ovl (sys::file_stat::is_dir (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
991 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
992
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
993 DEFUNX ("S_ISCHR", FS_ISCHR, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
994 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
995 @deftypefn {} {@var{tf} =} S_ISCHR (@var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
996 Return true if @var{mode} corresponds to a character device.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
997
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
998 The value of @var{mode} is assumed to be returned from a call to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
999 @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1000 @seealso{stat, lstat}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1001 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1002 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1003 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1004 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1005
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1006 double mode = args(0).xdouble_value ("S_ISCHR: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1007
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1008 return ovl (sys::file_stat::is_chr (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1009 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1010
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1011 DEFUNX ("S_ISBLK", FS_ISBLK, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1012 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1013 @deftypefn {} {@var{tf} =} S_ISBLK (@var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1014 Return true if @var{mode} corresponds to a block device.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1015
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1016 The value of @var{mode} is assumed to be returned from a call to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1017 @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1018 @seealso{stat, lstat}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1019 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1020 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1021 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1022 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1023
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1024 double mode = args(0).xdouble_value ("S_ISBLK: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1025
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1026 return ovl (sys::file_stat::is_blk (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1027 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1028
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1029 DEFUNX ("S_ISFIFO", FS_ISFIFO, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1030 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1031 @deftypefn {} {@var{tf} =} S_ISFIFO (@var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1032 Return true if @var{mode} corresponds to a fifo.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1033
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1034 The value of @var{mode} is assumed to be returned from a call to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1035 @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1036 @seealso{stat, lstat}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1037 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1038 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1039 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1040 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1041
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1042 double mode = args(0).xdouble_value ("S_ISFIFO: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1043
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1044 return ovl (sys::file_stat::is_fifo (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1045 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1046
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1047 DEFUNX ("S_ISLNK", FS_ISLNK, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1048 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1049 @deftypefn {} {@var{tf} =} S_ISLNK (@var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1050 Return true if @var{mode} corresponds to a symbolic link.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1051
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1052 The value of @var{mode} is assumed to be returned from a call to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1053 @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1054 @seealso{stat, lstat}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1055 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1056 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1057 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1058 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1059
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1060 double mode = args(0).xdouble_value ("S_ISLNK: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1061
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1062 return ovl (sys::file_stat::is_lnk (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1063 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1064
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1065 DEFUNX ("S_ISSOCK", FS_ISSOCK, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1066 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1067 @deftypefn {} {@var{tf} =} S_ISSOCK (@var{mode})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1068 Return true if @var{mode} corresponds to a socket.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1069
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1070 The value of @var{mode} is assumed to be returned from a call to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1071 @code{stat}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1072 @seealso{stat, lstat}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1073 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1074 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1075 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1076 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1077
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1078 double mode = args(0).xdouble_value ("S_ISSOCK: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1079
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1080 return ovl (sys::file_stat::is_sock (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1081 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1082
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1083 DEFUN (gethostname, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1084 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1085 @deftypefn {} {@var{name} =} gethostname ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1086 Return the hostname of the system where Octave is running.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1087 @end deftypefn */)
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1088 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1089 if (args.length () != 0)
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1090 print_usage ();
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1091
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1092 return ovl (sys::env::get_host_name ());
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1093 }
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1094
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1095 DEFUN (uname, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1096 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1097 @deftypefn {} {[@var{uts}, @var{err}, @var{msg}] =} uname ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1098 Return system information in the structure.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1099
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1100 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1101
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1102 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1103 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1104 uname ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1105 @result{} @{
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1106 sysname = x86_64
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1107 nodename = segfault
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1108 release = 2.6.15-1-amd64-k8-smp
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1109 version = Linux
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1110 machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1111 @}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1112 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1113 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1114
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1115 If successful, @var{err} is 0 and @var{msg} is an empty string.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1116 Otherwise, @var{err} is nonzero and @var{msg} contains a
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1117 system-dependent error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1118 @end deftypefn */)
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1119 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1120 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1121 print_usage ();
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1122
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1123 sys::uname sysinfo;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1124
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1125 octave_scalar_map m;
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1126
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1127 m.assign ("sysname", sysinfo.sysname ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1128 m.assign ("nodename", sysinfo.nodename ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1129 m.assign ("release", sysinfo.release ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1130 m.assign ("version", sysinfo.version ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1131 m.assign ("machine", sysinfo.machine ());
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1132
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1133 return ovl (m, sysinfo.error (), sysinfo.message ());
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1134 }
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1135
23957
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1136 /*
26946
04e5cb5e2cb3 update bug status in tests
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
1137 %!test <*51869>
23957
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1138 %! [info, status, msg] = uname ();
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1139 %! if (status == 0)
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1140 %! assert (isstruct (info))
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1141 %! assert (ischar (msg) && isempty (msg))
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1142 %! endif
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1143 */
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1144
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1145 DEFMETHODX ("unlink", Funlink, interp, args, nargout,
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
1146 doc: /* -*- texinfo -*-
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1147 @deftypefn {} {} unlink (@var{file})
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1148 @deftypefnx {} {[@var{status}, @var{msg}] =} unlink (@var{file})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1149 Delete the file named @var{file}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1150
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1151 If successful, @var{status} is 0 and @var{msg} is an empty string.
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1152 Otherwise, @var{status} is -1 and @var{msg} contains a system-dependent
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1153 error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1154 @seealso{delete, rmdir}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1155 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1156 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1157 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1158 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1159
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1160 std::string name = args(0).xstring_value ("unlink: FILE must be a string");
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1161
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1162 octave_value_list retval;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1163 std::string msg;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1164
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1165 event_manager& evmgr = interp.get_event_manager ();
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
1166
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1167 evmgr.file_remove (name, "");
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25113
diff changeset
1168
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1169 int status = sys::unlink (name, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1170
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1171 evmgr.file_renamed (status == 0);
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25113
diff changeset
1172
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1173 if (nargout == 0)
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1174 {
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1175 if (status < 0)
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1176 error ("unlink: operation failed: %s", msg.c_str ());
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1177 }
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1178 else
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1179 {
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1180 if (status < 0)
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1181 retval = ovl (-1.0, msg);
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1182 else
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1183 retval = ovl (0.0, "");
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1184 }
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1185
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1186 return retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1187 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1188
27040
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1189 /*
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1190 %!test
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1191 %! file = tempname ();
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1192 %! fid = fopen (file, "wt");
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1193 %! if (fid < 0)
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1194 %! error ("Could not open temporary file for unlink BIST test");
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1195 %! endif
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1196 %! fdisp (fid, pi);
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1197 %! fclose (fid);
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1198 %! [status, msg] = unlink (file);
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1199 %! assert (status, 0);
27040
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1200 %! assert (msg, "");
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1201
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1202 ## Test input validation
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1203 %!error <Invalid call> unlink ()
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1204 %!error <Invalid call> unlink ("a", "b")
27040
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1205 %!error <FILE must be a string> unlink (123)
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1206 */
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1207
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
1208 DEFUNX ("waitpid", Fwaitpid, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1209 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1210 @deftypefn {} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1211 Wait for process @var{pid} to terminate.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1212
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1213 The @var{pid} argument can be:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1214
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1215 @table @asis
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1216 @item @minus{}1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1217 Wait for any child process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1218
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1219 @item 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1220 Wait for any child process whose process group ID is equal to that of the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1221 Octave interpreter process.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1222
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1223 @item > 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1224 Wait for termination of the child process with ID @var{pid}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1225 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1226
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1227 The @var{options} argument can be a bitwise OR of zero or more of the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1228 following constants:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1229
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1230 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1231 @item 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1232 Wait until signal is received or a child process exits (this is the default
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1233 if the @var{options} argument is missing).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1234
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1235 @item WNOHANG
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1236 Do not hang if status is not immediately available.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1237
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1238 @item WUNTRACED
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1239 Report the status of any child processes that are stopped, and whose status
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1240 has not yet been reported since they stopped.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1241
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1242 @item WCONTINUE
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1243 Return if a stopped child has been resumed by delivery of @code{SIGCONT}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1244 This value may not be meaningful on all systems.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1245 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1246
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1247 If the returned value of @var{pid} is greater than 0, it is the process ID
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1248 of the child process that exited. If an error occurs, @var{pid} will be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1249 less than zero and @var{msg} will contain a system-dependent error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1250 The value of @var{status} contains additional system-dependent information
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1251 about the subprocess that exited.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1252 @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1253 WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1254 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1255 {
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1256 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1257
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1258 if (nargin != 1 && nargin != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1259 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1260
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1261 pid_t pid = args(0).strict_int_value ("waitpid: OPTIONS must be an integer");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1262
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1263 int options = 0;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1264
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1265 if (nargin == 2)
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1266 options = args(1).strict_int_value ("waitpid: PID must be an integer value");
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1267
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1268 std::string msg;
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1269 int status;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1270
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1271 pid_t result = sys::waitpid (pid, &status, options, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1272
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1273 return ovl (result, status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1274 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1275
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1276 DEFUNX ("WIFEXITED", FWIFEXITED, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1277 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1278 @deftypefn {} {@var{tf} =} WIFEXITED (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1279 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1280 true if the child terminated normally.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1281 @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1282 WSTOPSIG, WIFCONTINUED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1283 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1284 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1285 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1286 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1287
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1288 int status = args(0).strict_int_value ("WIFEXITED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1289
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1290 return ovl (sys::wifexited (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1291 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1292
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1293 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1294 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1295 @deftypefn {} {@var{tf} =} WEXITSTATUS (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1296 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1297 the exit status of the child.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1298
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1299 This function should only be employed if @code{WIFEXITED} returned true.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1300 @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1301 WSTOPSIG, WIFCONTINUED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1302 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1303 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1304 if (args.length () != 1)
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1305 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1306
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1307 int status = args(0).strict_int_value ("WEXITSTATUS: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1308
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1309 return ovl (sys::wexitstatus (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1310 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1311
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1312 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1313 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1314 @deftypefn {} {@var{tf} =} WIFSIGNALED (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1315 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1316 true if the child process was terminated by a signal.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1317 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1318 WSTOPSIG, WIFCONTINUED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1319 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1320 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1321 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1322 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1323
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1324 int status = args(0).strict_int_value ("WIFSIGNALED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1325
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1326 return ovl (sys::wifsignaled (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1327 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1328
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1329 DEFUNX ("WTERMSIG", FWTERMSIG, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1330 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1331 @deftypefn {} {@var{tf} =} WTERMSIG (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1332 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1333 the number of the signal that caused the child process to terminate.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1334
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1335 This function should only be employed if @code{WIFSIGNALED} returned true.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1336 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1337 WSTOPSIG, WIFCONTINUED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1338 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1339 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1340 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1341 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1342
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1343 int status = args(0).strict_int_value ("WTERMSIG: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1344
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1345 return ovl (sys::wtermsig (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1346 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1347
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1348 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1349 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1350 @deftypefn {} {@var{tf} =} WCOREDUMP (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1351 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1352 true if the child produced a core dump.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1353
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1354 This function should only be employed if @code{WIFSIGNALED} returned true.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1355 The macro used to implement this function is not specified in POSIX.1-2001
25003
2365c2661b3c doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
1356 and is not available on some Unix implementations (e.g., @nospell{AIX, SunOS}).
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1357 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1358 WSTOPSIG, WIFCONTINUED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1359 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1360 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1361 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1362 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1363
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1364 int status = args(0).strict_int_value ("WCOREDUMP: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1365
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1366 return ovl (sys::wcoredump (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1367 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1368
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1369 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1370 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1371 @deftypefn {} {@var{tf} =} WIFSTOPPED (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1372 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1373 true if the child process was stopped by delivery of a signal.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1374
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1375 This is only possible if the call was done using @code{WUNTRACED} or when
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1376 the child is being traced (see ptrace(2)).
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1377 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1378 WSTOPSIG, WIFCONTINUED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1379 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1380 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1381 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1382 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1383
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1384 int status = args(0).strict_int_value ("WIFSTOPPED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1385
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1386 return ovl (sys::wifstopped (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1387 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1388
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1389 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1390 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1391 @deftypefn {} {@var{tf} =} WSTOPSIG (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1392 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1393 the number of the signal which caused the child to stop.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1394
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1395 This function should only be employed if @code{WIFSTOPPED} returned true.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1396 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1397 WIFSTOPPED, WIFCONTINUED}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1398 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1399 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1400 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1401 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1402
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1403 int status = args(0).strict_int_value ("WSTOPSIG: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1404
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1405 return ovl (sys::wstopsig (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1406 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1407
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1408 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1409 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1410 @deftypefn {} {@var{tf} =} WIFCONTINUED (@var{status})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1411 Given @var{status} from a call to @code{waitpid}, return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1412 true if the child process was resumed by delivery of @code{SIGCONT}.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1413 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1414 WIFSTOPPED, WSTOPSIG}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1415 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1416 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1417 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1418 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1419
33446
5fded8395daa rename yTYPE_value functions strict_TYPE_value
John W. Eaton <jwe@octave.org>
parents: 33365
diff changeset
1420 int status = args(0).strict_int_value ("WIFCONTINUED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1421
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1422 return ovl (sys::wifcontinued (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1423 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1424
10249
14eba566f9f0 use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
1425 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1426 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1427 @deftypefn {} {[@var{cname}, @var{status}, @var{msg}] =} canonicalize_file_name (@var{fname})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1428 Return the canonical name of file @var{fname}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1429
28292
5bf3f462c11e Document that make_absolute_filename and canonicalize_file_name do not
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27923
diff changeset
1430 If the file does not exist the empty string ("") is returned. No tilde
5bf3f462c11e Document that make_absolute_filename and canonicalize_file_name do not
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 27923
diff changeset
1431 expansion of @var{fname} is performed.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1432 @seealso{make_absolute_filename, is_absolute_filename,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1433 is_rooted_relative_filename, is_same_file, tilde_expand}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1434 @end deftypefn */)
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1435 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1436 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1437 print_usage ();
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1438
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1439 std::string name = args(0).xstring_value ("canonicalize_file_name: NAME must be a string");
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1440
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1441 std::string msg;
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
1442
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1443 std::string result = sys::canonicalize_file_name (name, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1444
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1445 return ovl (result, msg.empty () ? 0 : -1, msg);
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1446 }
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1447
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1448 static inline octave_value
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1449 const_value (const octave_value_list& args, int val)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1450 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1451 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1452 print_usage ();
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1453
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1454 return octave_value (val);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1455 }
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1456
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1457 DEFUNX ("F_DUPFD", FF_DUPFD, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1458 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1459 @deftypefn {} {@var{v} =} F_DUPFD ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1460 Return the numerical value to pass to @code{fcntl} to return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1461 a duplicate file descriptor.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1462 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1463 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1464 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1465 static const int val = octave_f_dupfd_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1466
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1467 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1468 err_disabled_feature ("F_DUPFD", "F_DUPFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1469
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1470 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1471 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1472
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1473 DEFUNX ("F_GETFD", FF_GETFD, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1474 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1475 @deftypefn {} {@var{v} =} F_GETFD ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1476 Return the numerical value to pass to @code{fcntl} to return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1477 the file descriptor flags.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1478 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1479 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1480 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1481 static const int val = octave_f_getfd_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1482
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1483 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1484 err_disabled_feature ("F_GETFD", "F_GETFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1485
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1486 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1487 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1488
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1489 DEFUNX ("F_GETFL", FF_GETFL, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1490 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1491 @deftypefn {} {@var{v} =} F_GETFL ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1492 Return the numerical value to pass to @code{fcntl} to return
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1493 the file status flags.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1494 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1495 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1496 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1497 static const int val = octave_f_getfl_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1498
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1499 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1500 err_disabled_feature ("F_GETFL", "F_GETFL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1501
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1502 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1503 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1504
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1505 DEFUNX ("F_SETFD", FF_SETFD, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1506 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1507 @deftypefn {} {@var{v} =} F_SETFD ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1508 Return the numerical value to pass to @code{fcntl} to set the file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1509 descriptor flags.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1510 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1511 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1512 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1513 static const int val = octave_f_setfd_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1514
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1515 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1516 err_disabled_feature ("F_SETFD", "F_SETFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1517
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1518 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1519 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1520
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1521 DEFUNX ("F_SETFL", FF_SETFL, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1522 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1523 @deftypefn {} {@var{v} =} F_SETFL ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1524 Return the numerical value to pass to @code{fcntl} to set the file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1525 status flags.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1526 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1527 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1528 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1529 static const int val = octave_f_setfl_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1530
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1531 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1532 err_disabled_feature ("F_SETFL", "F_SETFL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1533
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1534 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1535 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1536
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1537 DEFUNX ("O_APPEND", FO_APPEND, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1538 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1539 @deftypefn {} {@var{v} =} O_APPEND ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1540 Return the numerical value of the @code{O_APPEND} macro.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1541
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1542 @code{O_APPEND} is file status flag that may be returned by @code{fcntl}
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1543 to indicate each write operation appends, or that may be passed to
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1544 @code{fcntl} to set the write mode to append.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1545 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1546 O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1547 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1548 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1549 static const int val = octave_o_append_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1550
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1551 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1552 err_disabled_feature ("O_APPEND", "O_APPEND");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1553
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1554 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1555 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1556
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1557 DEFUNX ("O_ASYNC", FO_ASYNC, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1558 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1559 @deftypefn {} {@var{v} =} O_ASYNC ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1560 Return the numerical value of the @code{O_ASYNC} macro.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1561
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1562 @code{O_ASYNC} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1563 @code{fcntl} to indicate asynchronous I/O.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1564 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1565 O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1566 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1567 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1568 static const int val = octave_o_async_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1569
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1570 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1571 err_disabled_feature ("O_ASYNC", "O_ASYNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1572
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1573 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1574 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1575
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1576 DEFUNX ("O_CREAT", FO_CREAT, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1577 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1578 @deftypefn {} {@var{v} =} O_CREAT ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1579 Return the numerical value of the @code{O_CREAT}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1580
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1581 @code{O_CREAT} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1582 @code{fcntl} to indicate that a file should be created if it does not
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1583 exist.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1584 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1585 O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1586 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1587 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1588 static const int val = octave_o_creat_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1589
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1590 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1591 err_disabled_feature ("O_CREAT", "O_CREAT");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1592
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1593 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1594 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1595
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1596 DEFUNX ("O_EXCL", FO_EXCL, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1597 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1598 @deftypefn {} {@var{v} =} O_EXCL ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1599 Return the numerical value of the @code{O_EXCL}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1600
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1601 @code{O_EXCL} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1602 @code{fcntl} to indicate that file locking is used.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1603 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1604 O_SYNC, O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1605 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1606 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1607 static const int val = octave_o_excl_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1608
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1609 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1610 err_disabled_feature ("O_EXCL", "O_EXCL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1611
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1612 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1613 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1614
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1615 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1616 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1617 @deftypefn {} {@var{v} =} O_NONBLOCK ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1618 Return the numerical value of the @code{O_NONBLOCK}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1619
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1620 @code{O_NONBLOCK} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1621 @code{fcntl} to indicate that non-blocking I/O is in use, or that may be
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1622 passsed to @code{fcntl} to set non-blocking I/O.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1623 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1624 O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1625 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1626 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1627 static const int val = octave_o_nonblock_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1628
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1629 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1630 err_disabled_feature ("O_NONBLOCK", "O_NONBLOCK");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1631
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1632 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1633 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1634
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1635 DEFUNX ("O_RDONLY", FO_RDONLY, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1636 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1637 @deftypefn {} {@var{v} =} O_RDONLY ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1638 Return the numerical value of the @code{O_RDONLY}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1639
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1640 @code{O_RDONLY} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1641 @code{fcntl} to indicate that a file is open for reading only.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1642 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1643 O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1644 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1645 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1646 static const int val = octave_o_rdonly_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1647
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1648 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1649 err_disabled_feature ("O_RDONLY", "O_RDONLY");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1650
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1651 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1652 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1653
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1654 DEFUNX ("O_RDWR", FO_RDWR, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1655 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1656 @deftypefn {} {@var{v} =} O_RDWR ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1657 Return the numerical value of the @code{O_RDWR}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1658
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1659 @code{O_RDWR} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1660 @code{fcntl} to indicate that a file is open for both reading and
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1661 writing.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1662 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1663 O_SYNC, O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1664 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1665 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1666 static const int val = octave_o_rdwr_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1667
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1668 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1669 err_disabled_feature ("O_RDWR", "O_RDWR");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1670
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1671 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1672 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1673
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1674 DEFUNX ("O_SYNC", FO_SYNC, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1675 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1676 @deftypefn {} {@var{v} =} O_SYNC ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1677 Return the numerical value of the @code{O_SYNC}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1678
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1679 @code{O_SYNC} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1680 @code{fcntl} to indicate that a file is open for synchronous I/O
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1681 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1682 O_RDWR, O_TRUNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1683 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1684 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1685 static const int val = octave_o_sync_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1686
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1687 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1688 err_disabled_feature ("O_SYNC", "O_SYNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1689
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1690 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1691 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1692
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1693 DEFUNX ("O_TRUNC", FO_TRUNC, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1694 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1695 @deftypefn {} {@var{v} =} O_TRUNC ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1696 Return the numerical value of the @code{O_TRUNC}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1697
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1698 @code{O_TRUNC} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1699 @code{fcntl} to indicate that if file exists, it should be truncated
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1700 when writing.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1701 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1702 O_RDWR, O_SYNC, O_WRONLY}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1703 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1704 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1705 static const int val = octave_o_trunc_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1706
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1707 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1708 err_disabled_feature ("O_TRUNC", "O_TRUNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1709
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1710 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1711 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1712
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1713 DEFUNX ("O_WRONLY", FO_WRONLY, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1714 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1715 @deftypefn {} {@var{v} =} O_WRONLY ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1716 Return the numerical value of the @code{O_WRONLY}.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1717
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1718 @code{O_WRONLY} is the file status flag that may be returned by
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1719 @code{fcntl} to indicate that a file is open for writing only
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1720 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29991
diff changeset
1721 O_RDWR, O_SYNC, O_TRUNC}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1722 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1723 {
31187
0a2bf14dd400 Add "const" qualifier to static variables that hold "fcntl.h" values.
Rik <rik@octave.org>
parents: 30888
diff changeset
1724 static const int val = octave_o_wronly_wrapper ();
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1725
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1726 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1727 err_disabled_feature ("O_WRONLY", "O_WRONLY");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1728
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1729 return const_value (args, val);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1730 }
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 3360
diff changeset
1731
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1732 DEFUNX ("WNOHANG", FWNOHANG, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1733 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1734 @deftypefn {} {@var{v} =} WNOHANG ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1735 Return the numerical value of the @code{WNOHANG} macro.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1736
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1737 @code{WNOHANG} is the option argument that may be passed to
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1738 @code{waitpid} to indicate that it should return its status immediately
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1739 instead of waiting for a process to exit.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1740 @seealso{waitpid, WUNTRACED, WCONTINUE}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1741 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1742 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1743 return const_value (args, sys::wnohang ());
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1744 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1745
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1746 DEFUNX ("WUNTRACED", FWUNTRACED, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1747 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1748 @deftypefn {} {@var{v} =} WUNTRACED ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1749 Return the numerical value of the @code{WUNTRACED} macro.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1750
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1751 @code{WUNTRACED} is the option argument that may be passed to
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1752 @code{waitpid} to indicate that it should also return if the child
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1753 process has stopped but is not traced via the @code{ptrace} system call
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1754 @seealso{waitpid, WNOHANG, WCONTINUE}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1755 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1756 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1757 return const_value (args, sys::wuntraced ());
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1758 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1759
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1760 DEFUNX ("WCONTINUE", FWCONTINUE, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1761 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30826
diff changeset
1762 @deftypefn {} {@var{v} =} WCONTINUE ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1763 Return the numerical value of the @code{WCONTINUE} macro.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1764
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1765 @code{WCONTINUE} is the option argument that may be passed to
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1766 @code{waitpid} to indicate that it should also return if a stopped child
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1767 has been resumed by delivery of a @code{SIGCONT} signal.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1768 @seealso{waitpid, WNOHANG, WUNTRACED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1769 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1770 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1771 return const_value (args, sys::wcontinue ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1772 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
1773
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31187
diff changeset
1774 OCTAVE_END_NAMESPACE(octave)