annotate libinterp/corefcn/syscalls.cc @ 28102:4d021e0dcfee

fcntl: throw error if operation fails and nargout == 0 (bug #57830). * syscalls.cc (Ffcntl): Add nargout to DEFUN macro invocation. Add command calling form to documentation. Rename "err" to "status" in documentation. Document that status variable is -1 if an error is encountered. Based on nargout variable, either throw an error if operation failed, or return status and msg information.
author Rik <rik@octave.org>
date Tue, 18 Feb 2020 16:46:15 -0800
parents 43c2d9c03cc7
children a01ad9893641
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 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1996-2020 The Octave Project Developers
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
21949
baeffde5c87d fix build for Windows systems
John W. Eaton <jwe@octave.org>
parents: 21937
diff changeset
35 #include <ctime>
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
36 #include <cstdio>
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
37 #include <cstring>
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
38
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
39 #include "cmd-hist.h"
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
40 #include "fcntl-wrappers.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
41 #include "file-ops.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
42 #include "file-stat.h"
22087
7f79c716876c eliminate unused parameter from octave::sys::popen2
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
43 #include "lo-utils.h"
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
44 #include "oct-env.h"
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
45 #include "oct-syscalls.h"
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
46 #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
47
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
48 #include "defun.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
49 #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
50 #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
51 #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
52 #include "input.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
53 #include "interpreter.h"
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
54 #include "oct-hist.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
55 #include "oct-map.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
56 #include "oct-stdstrm.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
57 #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
58 #include "ovl.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
59 #include "sysdep.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
60 #include "utils.h"
2366
c90105b99479 [project @ 1996-10-11 23:22:27 by jwe]
jwe
parents: 2305
diff changeset
61 #include "variables.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
62
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
63 static octave_scalar_map
21737
ab6c639f0678 finish previous changeset (0504351a45e6).
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
64 mk_stat_map (const octave::sys::base_file_stat& fs)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
65 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
66 static bool have_rdev
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
67 = octave::sys::base_file_stat::have_struct_stat_st_rdev ();
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
68 static bool have_blksize
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
69 = octave::sys::base_file_stat::have_struct_stat_st_blksize ();
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
70 static bool have_blocks
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
71 = octave::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
72
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
73 static double nan = octave::numeric_limits<double>::NaN ();
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
74
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
75 octave_scalar_map m;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
76
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
77 m.assign ("dev", static_cast<double> (fs.dev ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
78 m.assign ("ino", fs.ino ());
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
79 m.assign ("mode", fs.mode ());
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
80 m.assign ("modestr", fs.mode_as_string ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
81 m.assign ("nlink", fs.nlink ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
82 m.assign ("uid", fs.uid ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
83 m.assign ("gid", fs.gid ());
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
84 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
85 m.assign ("size", fs.size ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
86 m.assign ("atime", fs.atime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
87 m.assign ("mtime", fs.mtime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
88 m.assign ("ctime", fs.ctime ());
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
89
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
90 if (have_blksize)
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
91 m.assign ("blksize", fs.blksize ());
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
92 else
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
93 m.assign ("blksize", nan);
21937
55f7de37b618 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21935
diff changeset
94
21935
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
95 if (have_blocks)
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
96 m.assign ("blocks", fs.blocks ());
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
97 else
2f33052c68ff hide sys/stat.h header
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
98 m.assign ("blocks", nan);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
99
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
100 return m;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
101 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
102
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
103 static octave_value_list
21737
ab6c639f0678 finish previous changeset (0504351a45e6).
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
104 mk_stat_result (const octave::sys::base_file_stat& fs)
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
105 {
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
106 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
107 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
108 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
109 return ovl (Matrix (), -1, fs.error ());
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
110 }
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
111
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
112 DEFMETHODX ("dup2", Fdup2, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
113 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
114 @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
115 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
116
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
117 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
118 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
119 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
120 @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
121 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
122 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20800
diff changeset
123 if (args.length () != 2)
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
124 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
125
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
126 octave::stream_list& streams = interp.get_stream_list ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
127
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
128 octave::stream old_stream = streams.lookup (args(0), "dup2");
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
129
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
130 octave::stream new_stream = streams.lookup (args(1), "dup2");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
131
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
132 int i_old = old_stream.file_number ();
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
133 int i_new = new_stream.file_number ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
134
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
135 if (i_old >= 0 && i_new >= 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
136 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
137 std::string msg;
3341
14cfc9475fe4 [project @ 1999-11-05 08:11:58 by jwe]
jwe
parents: 3340
diff changeset
138
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
139 int status = octave::sys::dup2 (i_old, i_new, msg);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
140
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
141 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
142 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
143 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
144 return ovl (-1, "");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
145 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
146
25994
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
147 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
148 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
149 @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
150 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
151
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
152 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
153 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
154 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
155
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
156 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
157 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
158 @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
159
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
160 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
161 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
162
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
163 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
164 @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
165 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
166 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
167 {
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
168 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
169
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
170 if (nargin < 1 || nargin > 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
171 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
172
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
173 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
174
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
175 string_vector exec_args;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
176
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
177 if (nargin == 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
178 {
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20956
diff changeset
179 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
180
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
181 int len = tmp.numel ();
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 exec_args.resize (len + 1);
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
184
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
185 exec_args[0] = exec_file;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
186
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
187 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
188 exec_args[i+1] = tmp[i];
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
189 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
190 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
191 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
192 exec_args.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
193
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
194 exec_args[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
195 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
196
25994
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
197 octave::history_system& history_sys = interp.get_history_system ();
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
198
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25782
diff changeset
199 history_sys.write_timestamp ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
200
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21737
diff changeset
201 if (! octave::command_history::ignoring_entries ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21737
diff changeset
202 octave::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
203
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
204 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
205
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
206 int status = octave::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
207
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
208 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
209 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
210
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
211 DEFMETHODX ("popen2", Fpopen2, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
212 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
213 @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
214 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
215
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
216 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
217 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
218
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
219 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
220 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
221 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
222 @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
223
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
224 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
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 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
227 [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
228 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
229 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
230 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
231 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
232 do
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
233 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
234 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
235 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
236 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
237 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
238 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
239 else
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
240 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
241 endif
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
242 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
243 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
244 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
245
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
246 @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
247 @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
248 @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
249 @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
250 @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
251
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
252 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
253 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
254 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
255 @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
256 @end deftypefn */)
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
257 {
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
258 int nargin = args.length ();
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
259
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
260 if (nargin < 1 || nargin > 3)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
261 print_usage ();
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
262
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
263 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
264
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
265 string_vector arg_list;
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
266
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
267 if (nargin >= 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
268 {
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20956
diff changeset
269 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
270
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
271 int len = tmp.numel ();
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 arg_list.resize (len + 1);
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 arg_list[0] = exec_file;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
276
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
277 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
278 arg_list[i+1] = tmp[i];
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
279 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
280 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
281 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
282 arg_list.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
283
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
284 arg_list[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
285 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
286
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
287 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
288
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
289 int filedesc[2];
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
290 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
291 pid_t pid;
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
292
22087
7f79c716876c eliminate unused parameter from octave::sys::popen2
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
293 pid = octave::sys::popen2 (exec_file, arg_list, sync_mode, filedesc, msg);
7f79c716876c eliminate unused parameter from octave::sys::popen2
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
294
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
295 if (pid < 0)
26149
242aa7b2c783 Silence unnecessary warnings about security-format (bug #55046).
Rik <rik@octave.org>
parents: 25994
diff changeset
296 error ("%s", msg.c_str ());
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
297
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
298 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
299 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
300
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
301 octave::stream is
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
302 = octave_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
303
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
304 octave::stream os
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
305 = octave_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
306
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
307 octave::stream_list& streams = interp.get_stream_list ();
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
308
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
309 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
310 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
311
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
312 /*
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
313
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
314 %!test # UNIX-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
315 %! if (isunix () || ismac ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
316 %! [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
317 %! EAGAIN = errno ("EAGAIN");
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
318 %! fputs (in, "these\nare\nsome\nstrings\n");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
319 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
320 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
321 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
322 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
323 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
324 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
325 %! if (ismac ()) # FIXME: Is this necessary?
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
326 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
327 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
328 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
329 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
330 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
331 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
332 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
333 %! 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
334 %! pause (0.1);
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
335 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
336 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
337 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
338 %! else
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
339 %! done = true;
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
340 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
341 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
342 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
343 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
344 %! 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
345 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
346
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
347 %!test # Windows-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
348 %! if (ispc () && ! isunix ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
349 %! [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
350 %! EAGAIN = errno ("EINVAL");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
351 %! 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
352 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
353 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
354 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
355 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
356 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
357 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
358 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
359 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
360 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
361 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
362 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
363 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
364 %! 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
365 %! pause (0.1);
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
366 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
367 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
368 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
369 %! else
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
370 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
371 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
372 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
373 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
374 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
375 %! 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
376 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
377
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
378 */
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
379
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
380 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
381 doc: /* -*- texinfo -*-
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
382 @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
383 @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
384 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
385
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
386 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
387
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
388 @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
389 @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
390 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
391
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
392 @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
393 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
394
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
395 @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
396 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
397
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
398 @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
399 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
400 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
401
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
402 @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
403 @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
404 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
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 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
407 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
408
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
409 @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
410 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
411
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
412 @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
413 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
414
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
415 @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
416 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
417
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
418 @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
419 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
420
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
421 @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
422 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
423
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
424 @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
425 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
426 @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
427
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
428 @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
429 Set the file status flags for @var{fid} to the value specified by @var{arg}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
430 The only flags that can be changed are @w{@code{O_APPEND}} and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
431 @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
432 @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
433
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
434 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
435 @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
436 message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
437 @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
438 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
439 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
440 if (args.length () != 3)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
441 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
442
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
443 octave::stream_list& streams = interp.get_stream_list ();
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
444
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
445 octave::stream strm = streams.lookup (args(0), "fcntl");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
446
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
447 int fid = strm.file_number ();
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
448
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
449 // FIXME: Do we want to use xint_value and throw a warning message
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
450 // if input validation fails?
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
451 int req = args(1).int_value (true);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
452 int arg = args(2).int_value (true);
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
453
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
454 // FIXME: Need better checking here?
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
455 if (fid < 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
456 error ("fcntl: invalid file id");
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
457
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
458 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
459 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
460
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
461 int status = octave::sys::fcntl (fid, req, arg, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
462
28102
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
463 if (nargout == 0)
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
464 {
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
465 if (status < 0)
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
466 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
467 }
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
468 else
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
469 {
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
470 if (status < 0)
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
471 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
472 else
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
473 retval = ovl (0.0, "");
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
474 }
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
475
4d021e0dcfee fcntl: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28101
diff changeset
476 return retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
477 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
478
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
479 DEFMETHODX ("fork", Ffork, interp, args, ,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
480 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
481 @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
482 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
483
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
484 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
485
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
486 @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
487 @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
488 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
489 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
490 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
491
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
492 @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
493 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
494 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
495
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
496 @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
497 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
498 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
499 @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
500 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
501 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
502 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
503 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
504
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
505 if (interp.at_top_level ())
21604
d7a268e68e69 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21547
diff changeset
506 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
507
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
508 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
509
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
510 pid_t pid = octave::sys::fork (msg);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
511
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
512 return ovl (pid, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
513 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
514
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
515 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
516 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
517 @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
518 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
519 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
520 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
521 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
522 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
523
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
524 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
525
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
526 pid_t pid = octave::sys::getpgrp (msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
527
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
528 return ovl (pid, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
529 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
530
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
531 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
532 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
533 @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
534 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
535 @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
536 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
537 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
538 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
539 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
540
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
541 return ovl (octave::sys::getpid ());
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 ("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
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 =} getppid ()
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 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
548 @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
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 ();
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
553
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
554 return ovl (octave::sys::getppid ());
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
555 }
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
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 ("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
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 {} {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
560 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
561 @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
562 @end deftypefn */)
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
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
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
567 return ovl (octave::sys::getegid ());
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 ("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
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 {} {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
573 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
574 @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
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 ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
579
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
580 return ovl (octave::sys::getgid ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
581 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
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 ("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
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 {} {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
586 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
587 @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
588 @end deftypefn */)
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
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 ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
592
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
593 return ovl (octave::sys::geteuid ());
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
594 }
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
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 ("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
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 {} {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
599 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
600 @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
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
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
606 return ovl (octave::sys::getuid ());
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
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
609 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
610 doc: /* -*- texinfo -*-
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
611 @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
612 @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
613 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
614
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
615 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
616
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
617 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
618 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
619
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
620 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
621 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
622
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
623 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
624 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
625
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
626 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
627 performed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
628
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
629 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
630 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
631 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
632 @end deftypefn */)
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
633 {
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
634 if (args.length () != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
635 print_usage ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
636
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
637 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
638
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
639 int sig = args(1).int_value (true);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
640
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
641 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
642 std::string msg;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
643
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
644 int status = octave::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
645
28101
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
646 if (nargout == 0)
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
647 {
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
648 if (status < 0)
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
649 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
650 }
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
651 else
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
652 {
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
653 if (status < 0)
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
654 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
655 else
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
656 retval = ovl (0.0, "");
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
657 }
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
658
43c2d9c03cc7 kill: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28100
diff changeset
659 return retval;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
660 }
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
661
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
662 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
663 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
664 @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
665 @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
666 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
667 @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
668
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
669 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
670 @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
671 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
672 {
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
673 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
674 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
675
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
676 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
677
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
678 octave::sys::file_stat fs (fname, false);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
679
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
680 return mk_stat_result (fs);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
681 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
682
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
683 // 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
684 // 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
685 static int
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
686 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
687 {
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
688 int retval = 0;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
689
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
690 int tmp = x % obase;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
691
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
692 if (tmp > ibase - 1)
20428
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20232
diff changeset
693 error ("mkfifo: invalid digit");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
694
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
695 retval = tmp;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
696 int mult = ibase;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
697 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
698 {
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
699 tmp = x % obase;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
700
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
701 if (tmp > ibase - 1)
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
702 error ("mkfifo: invalid digit");
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
703
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
704 retval += mult * tmp;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
705 mult *= ibase;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
706 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
707
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
708 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
709 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
710
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
711 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
712 doc: /* -*- texinfo -*-
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
713 @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
714 @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
715 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
716
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
717 @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
718 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
719
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
720 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
721 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
722 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
723 @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
724 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
725 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
726 if (args.length () != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
727 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
728
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
729 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
730
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
731 int octal_mode = args(1).xint_value ("mkfifo: MODE must be an integer");
4254
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4233
diff changeset
732
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
733 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
734 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
735
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
736 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
737
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
738 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
739 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
740
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
741 int status = octave::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
742
28100
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
743 if (nargout == 0)
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
744 {
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
745 if (status < 0)
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
746 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
747 }
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
748 else
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
749 {
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
750 if (status < 0)
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
751 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
752 else
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
753 retval = ovl (0.0, "");
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
754 }
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
755
aa4eba65d227 mkfifo: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 28098
diff changeset
756 return retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
757 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
758
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
759 /*
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
760
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
761 ## Test input validation
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
762 %!error mkfifo ()
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
763 %!error mkfifo ("abc")
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
764 %!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
765 %!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
766 ## 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
767 #%!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
768 #%!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
769
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
770 */
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
771
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
772 DEFMETHODX ("pipe", Fpipe, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
773 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
774 @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
775 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
776 @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
777
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
778 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
779 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
780 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
781 @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
782 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
783 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
784 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
785 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
786
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
787 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
788 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
789
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
790 int status = octave::sys::pipe (fid, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
791
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
792 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
793 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
794 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
795 {
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
796 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
797 FILE *ofile = fdopen (fid[1], "w");
4327
c29c382a5b4b [project @ 2003-02-16 03:24:26 by jwe]
jwe
parents: 4294
diff changeset
798
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
799 octave::stream is
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
800 = octave_stdiostream::create ("pipe-in", ifile, std::ios::in);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
801
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
802 octave::stream os
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
803 = octave_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
804
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
805 octave::stream_list& streams = interp.get_stream_list ();
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
806
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
807 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
808 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
809 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
810
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
811 DEFMETHODX ("stat", Fstat, interp, args, ,
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
812 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
813 @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
814 @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
815 @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
816 @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
817 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
818 @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
819
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
820 @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
821 @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
822 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
823
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
824 @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
825 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
826
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
827 @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
828 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
829 @w{@code{S_ISDIR}}, @w{@code{S_ISCHR}}, @w{@code{S_ISBLK}},
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
830 @w{@code{S_ISFIFO}}, @w{@code{S_ISLNK}}, or @w{@code{S_ISSOCK}} to extract
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
831 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
832
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
833 @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
834 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
835 @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
836
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
837 @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
838 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
839
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
840 @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
841 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
842
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
843 @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
844 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
845
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
846 @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
847 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
848
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
849 @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
850 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
851
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
852 @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
853 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
854 @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
855
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
856 @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
857 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
858 @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
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 ctime
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
861 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
862 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
863
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
864 @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
865 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
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 blocks
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
868 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
869 @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
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 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
872 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
873 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
874 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
875
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
876 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
877 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
878 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
879
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
880 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
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 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
883 [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
884 @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
885 @{
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
886 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
887 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
888 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
889 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
890 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
891 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
892 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
893 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
894 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
895 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
896 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
897 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
898 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
899 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
900 @}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
901 @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
902 @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
903 @end example
25782
0862570da0ae isfile.m: New function for Matlab compatibility (bug #54508).
Rik <rik@octave.org>
parents: 25781
diff changeset
904 @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
905 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
906 {
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
907 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
908 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
909
2262
1300df4a33d6 [project @ 1996-05-23 06:49:32 by jwe]
jwe
parents: 2086
diff changeset
910 octave_value_list retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
911
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
912 if (args(0).is_scalar_type ())
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
913 {
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
914 octave::stream_list& streams = interp.get_stream_list ();
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
915
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
916 int fid = streams.get_file_number (args(0));
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
917
21737
ab6c639f0678 finish previous changeset (0504351a45e6).
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
918 octave::sys::file_fstat fs (fid);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
919
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
920 retval = mk_stat_result (fs);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
921 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
922 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
923 {
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
924 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
925
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
926 octave::sys::file_stat fs (fname);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
927
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
928 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
929 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
930
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
931 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
932 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
933
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
934 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
935 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
936 @deftypefn {} {} S_ISREG (@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
937 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
938
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
939 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
940 @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
941 @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
942 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
943 {
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
944 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
945 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
946
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
947 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
948
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
949 return ovl (octave::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
950 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
951
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
952 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
953 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
954 @deftypefn {} {} S_ISDIR (@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
955 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
956
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
957 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
958 @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
959 @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
960 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
961 {
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
962 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
963 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
964
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
965 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
966
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
967 return ovl (octave::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
968 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
969
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
970 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
971 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
972 @deftypefn {} {} S_ISCHR (@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
973 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
974
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
975 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
976 @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
977 @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
978 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
979 {
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
980 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
981 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
982
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
983 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
984
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
985 return ovl (octave::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
986 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
987
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
988 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
989 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
990 @deftypefn {} {} S_ISBLK (@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
991 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
992
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
993 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
994 @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
995 @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
996 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
997 {
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
998 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
999 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1000
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
1001 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
1002
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1003 return ovl (octave::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
1004 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1005
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1006 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
1007 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
1008 @deftypefn {} {} S_ISFIFO (@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
1009 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
1010
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1011 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
1012 @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
1013 @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
1014 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1015 {
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
1016 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1017 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1018
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
1019 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
1020
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1021 return ovl (octave::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
1022 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1023
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1024 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
1025 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
1026 @deftypefn {} {} S_ISLNK (@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
1027 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
1028
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1029 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
1030 @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
1031 @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
1032 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1033 {
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
1034 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1035 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1036
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
1037 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
1038
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1039 return ovl (octave::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
1040 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1041
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1042 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
1043 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
1044 @deftypefn {} {} S_ISSOCK (@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
1045 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
1046
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1047 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
1048 @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
1049 @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
1050 @end deftypefn */)
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1051 {
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
1052 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1053 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1054
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
1055 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
1056
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
1057 return ovl (octave::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
1058 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1059
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1060 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
1061 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
1062 @deftypefn {} {} gethostname ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1063 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
1064 @end deftypefn */)
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1065 {
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
1066 if (args.length () != 0)
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1067 print_usage ();
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1068
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21731
diff changeset
1069 return ovl (octave::sys::env::get_host_name ());
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1070 }
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1071
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1072 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
1073 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
1074 @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
1075 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
1076
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1077 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
1078
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1079 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1080 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1081 uname ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1082 @result{} @{
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1083 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
1084 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
1085 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
1086 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
1087 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
1088 @}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1089 @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
1090 @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
1091
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1092 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
1093 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
1094 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
1095 @end deftypefn */)
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1096 {
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
1097 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1098 print_usage ();
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1099
21731
3dfec4c1eb8b use namespace for system uname class
John W. Eaton <jwe@octave.org>
parents: 21727
diff changeset
1100 octave::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
1101
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1102 octave_scalar_map m;
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1103
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
1104 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
1105 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
1106 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
1107 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
1108 m.assign ("machine", sysinfo.machine ());
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1109
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1110 return ovl (m, sysinfo.error (), sysinfo.message ());
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1111 }
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1112
23957
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1113 /*
26946
04e5cb5e2cb3 update bug status in tests
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
1114 %!test <*51869>
23957
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1115 %! [info, status, msg] = uname ();
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1116 %! if (status == 0)
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1117 %! assert (isstruct (info))
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1118 %! 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
1119 %! endif
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1120 */
382cc01a60e1 uname: Return empty message on success (bug #51869)
Markus Mützel <markus.muetzel@gmx.de>
parents: 23738
diff changeset
1121
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1122 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
1123 doc: /* -*- texinfo -*-
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1124 @deftypefn {} {} unlink (@var{file})
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1125 @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
1126 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
1127
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1128 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
1129 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
1130 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
1131 @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
1132 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1133 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1134 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1135 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1136
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
1137 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
1138
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1139 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
1140 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
1141
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1142 octave::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
1143
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1144 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
1145
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
1146 int status = octave::sys::unlink (name, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1147
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1148 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
1149
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1150 if (nargout == 0)
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1151 {
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1152 if (status < 0)
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1153 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
1154 }
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1155 else
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1156 {
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1157 if (status < 0)
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1158 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
1159 else
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1160 retval = ovl (0.0, "");
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1161 }
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1162
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1163 return retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1164 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1165
27040
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1166 /*
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1167 %!test
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1168 %! file = tempname ();
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1169 %! fid = fopen (file, "wt");
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1170 %! if (fid < 0)
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1171 %! 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
1172 %! endif
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1173 %! fdisp (fid, pi);
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1174 %! fclose (fid);
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1175 %! [status, msg] = unlink (file);
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1176 %! assert (status, 0);
27040
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1177 %! assert (msg, "");
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1178
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1179 ## Test input validation
28098
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1180 %!error <Invalid call> unlink ()
501553fcf6e2 unlink: throw error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents: 27923
diff changeset
1181 %!error <Invalid call> unlink ("a", "b")
27040
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1182 %!error <FILE must be a string> unlink (123)
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1183 */
8c4f01b66c0b Add BIST tests for unlink() (bug #56097).
Rik <rik@octave.org>
parents: 26376
diff changeset
1184
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
1185 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
1186 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
1187 @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
1188 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
1189
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1190 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
1191
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1192 @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
1193 @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
1194 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
1195
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1196 @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
1197 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
1198 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
1199
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1200 @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
1201 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
1202 @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
1203
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1204 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
1205 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
1206
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1207 @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
1208 @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
1209 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
1210 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
1211
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1212 @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
1213 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
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 @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
1216 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
1217 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
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 WCONTINUE
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1220 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
1221 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
1222 @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
1223
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1224 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
1225 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
1226 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
1227 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
1228 about the subprocess that exited.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1229 @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1230 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1231 {
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1232 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1233
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
1234 if (nargin != 1 && nargin != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1235 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1236
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
1237 pid_t pid = args(0).xint_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
1238
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
1239 int options = 0;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1240
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1241 if (nargin == 2)
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
1242 options = args(1).xint_value ("waitpid: PID must be an integer value");
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1243
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
1244 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
1245 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
1246
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1247 pid_t result = octave::sys::waitpid (pid, &status, options, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1248
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1249 return ovl (result, status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1250 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1251
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1252 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
1253 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
1254 @deftypefn {} {} WIFEXITED (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1255 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
1256 true if the child terminated normally.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1257 @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1258 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1259 {
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
1260 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
1261 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
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 status = args(0).xint_value ("WIFEXITED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1264
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1265 return ovl (octave::sys::wifexited (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1266 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1267
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1268 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
1269 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
1270 @deftypefn {} {} WEXITSTATUS (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1271 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
1272 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
1273
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1274 This function should only be employed if @code{WIFEXITED} 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
1275 @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1276 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1277 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1278 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
1279 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1280
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1281 int status = args(0).xint_value ("WEXITSTATUS: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1282
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1283 return ovl (octave::sys::wexitstatus (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1284 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1285
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1286 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
1287 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
1288 @deftypefn {} {} WIFSIGNALED (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1289 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
1290 true if the child process was terminated by 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
1291 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1292 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1293 {
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
1294 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
1295 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1296
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
1297 int status = args(0).xint_value ("WIFSIGNALED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1298
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1299 return ovl (octave::sys::wifsignaled (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1300 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1301
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1302 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
1303 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
1304 @deftypefn {} {} WTERMSIG (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1305 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
1306 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
1307
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1308 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
1309 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1310 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1311 {
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
1312 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
1313 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1314
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
1315 int status = args(0).xint_value ("WTERMSIG: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1316
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1317 return ovl (octave::sys::wtermsig (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1318 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1319
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1320 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
1321 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
1322 @deftypefn {} {} WCOREDUMP (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1323 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
1324 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
1325
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1326 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
1327 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
1328 and is not available on some Unix implementations (e.g., @nospell{AIX, SunOS}).
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1329 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1330 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1331 {
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
1332 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
1333 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1334
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
1335 int status = args(0).xint_value ("WCOREDUMP: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1336
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1337 return ovl (octave::sys::wcoredump (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1338 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1339
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1340 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
1341 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
1342 @deftypefn {} {} WIFSTOPPED (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1343 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
1344 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
1345
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1346 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
1347 the child is being traced (see ptrace(2)).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1348 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WSTOPSIG, WIFCONTINUED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1349 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1350 {
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
1351 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
1352 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1353
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
1354 int status = args(0).xint_value ("WIFSTOPPED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1355
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1356 return ovl (octave::sys::wifstopped (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1357 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1358
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1359 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
1360 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
1361 @deftypefn {} {} WSTOPSIG (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1362 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
1363 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
1364
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1365 This function should only be employed if @code{WIFSTOPPED} 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
1366 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WIFCONTINUED}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1367 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1368 {
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
1369 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
1370 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1371
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
1372 int status = args(0).xint_value ("WSTOPSIG: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1373
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1374 return ovl (octave::sys::wstopsig (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1375 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1376
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1377 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
1378 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
1379 @deftypefn {} {} WIFCONTINUED (@var{status})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1380 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
1381 true if the child process was 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
1382 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1383 @end deftypefn */)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1384 {
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
1385 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
1386 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1387
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
1388 int status = args(0).xint_value ("WIFCONTINUED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1389
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1390 return ovl (octave::sys::wifcontinued (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1391 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1392
10249
14eba566f9f0 use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
1393 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
1394 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
1395 @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
1396 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
1397
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1398 If the file does not exist the empty string ("") is returned.
27571
24618a510749 Polish implementation of is_same_file().
Rik <rik@octave.org>
parents: 27277
diff changeset
1399 @seealso{make_absolute_filename, is_absolute_filename, is_rooted_relative_filename, is_same_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
1400 @end deftypefn */)
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1401 {
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
1402 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1403 print_usage ();
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1404
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
1405 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
1406
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
1407 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
1408
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
1409 std::string result = octave::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
1410
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1411 return ovl (result, msg.empty () ? 0 : -1, msg);
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1412 }
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1413
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1414 static inline octave_value
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1415 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
1416 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1417 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1418 print_usage ();
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1419
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1420 return octave_value (val);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1421 }
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1422
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1423 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
1424 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
1425 @deftypefn {} {} 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
1426 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
1427 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
1428 @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
1429 @end deftypefn */)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1430 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1431 static int val = octave_f_dupfd_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1432
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1433 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1434 err_disabled_feature ("F_DUPFD", "F_DUPFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1435
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1436 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
1437 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1438
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1439 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
1440 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
1441 @deftypefn {} {} 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
1442 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
1443 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
1444 @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
1445 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1446 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1447 static int val = octave_f_getfd_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1448
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1449 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1450 err_disabled_feature ("F_GETFD", "F_GETFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1451
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1452 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
1453 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1454
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1455 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
1456 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
1457 @deftypefn {} {} 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
1458 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
1459 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
1460 @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
1461 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1462 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1463 static int val = octave_f_getfl_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1464
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1465 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1466 err_disabled_feature ("F_GETFL", "F_GETFL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1467
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1468 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
1469 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1470
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1471 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
1472 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
1473 @deftypefn {} {} 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
1474 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
1475 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
1476 @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
1477 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1478 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1479 static int val = octave_f_setfd_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1480
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1481 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1482 err_disabled_feature ("F_SETFD", "F_SETFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1483
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1484 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
1485 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1486
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1487 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
1488 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
1489 @deftypefn {} {} 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
1490 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
1491 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
1492 @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
1493 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1494 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1495 static int val = octave_f_setfl_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1496
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1497 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1498 err_disabled_feature ("F_SETFL", "F_SETFL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1499
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1500 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
1501 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1502
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1503 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
1504 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
1505 @deftypefn {} {} O_APPEND ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1506 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
1507
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1508 @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
1509 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
1510 @code{fcntl} to set the write mode to append.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1511 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, 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
1512 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1513 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1514 static int val = octave_o_append_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1515
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1516 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1517 err_disabled_feature ("O_APPEND", "O_APPEND");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1518
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1519 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
1520 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1521
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1522 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
1523 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
1524 @deftypefn {} {} O_ASYNC ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1525 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
1526
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1527 @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
1528 @code{fcntl} to indicate asynchronous I/O.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1529 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, 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
1530 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1531 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1532 static int val = octave_o_async_wrapper ();
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 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1535 err_disabled_feature ("O_ASYNC", "O_ASYNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1536
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1537 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
1538 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1539
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1540 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
1541 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
1542 @deftypefn {} {} O_CREAT ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1543 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
1544
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1545 @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
1546 @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
1547 exist.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1548 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, 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
1549 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1550 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1551 static int val = octave_o_creat_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1552
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1553 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1554 err_disabled_feature ("O_CREAT", "O_CREAT");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1555
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1556 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
1557 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1558
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1559 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
1560 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
1561 @deftypefn {} {} O_EXCL ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1562 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
1563
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1564 @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
1565 @code{fcntl} to indicate that file locking is used.
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 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, 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
1567 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1568 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1569 static int val = octave_o_excl_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1570
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1571 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1572 err_disabled_feature ("O_EXCL", "O_EXCL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1573
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1574 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
1575 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1576
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1577 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
1578 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
1579 @deftypefn {} {} O_NONBLOCK ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1580 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
1581
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1582 @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
1583 @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
1584 passsed to @code{fcntl} to set non-blocking I/O.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1585 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, 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
1586 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1587 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1588 static int val = octave_o_nonblock_wrapper ();
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_NONBLOCK", "O_NONBLOCK");
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_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
1597 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
1598 @deftypefn {} {} O_RDONLY ()
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_RDONLY}.
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_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
1602 @code{fcntl} to indicate that a file is open for reading only.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1603 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, 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
1604 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1605 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1606 static int val = octave_o_rdonly_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1607
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1608 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1609 err_disabled_feature ("O_RDONLY", "O_RDONLY");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1610
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1611 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
1612 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1613
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1614 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
1615 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
1616 @deftypefn {} {} O_RDWR ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1617 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
1618
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1619 @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
1620 @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
1621 writing.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1622 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, 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
1623 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1624 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1625 static int val = octave_o_rdwr_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1626
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1627 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1628 err_disabled_feature ("O_RDWR", "O_RDWR");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1629
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1630 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
1631 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1632
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1633 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
1634 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
1635 @deftypefn {} {} O_SYNC ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1636 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
1637
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1638 @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
1639 @code{fcntl} to indicate that a file is open for synchronous I/O
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1640 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, 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
1641 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1642 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1643 static int val = octave_o_sync_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1644
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1645 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1646 err_disabled_feature ("O_SYNC", "O_SYNC");
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 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
1649 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1650
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1651 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
1652 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
1653 @deftypefn {} {} O_TRUNC ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1654 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
1655
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1656 @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
1657 @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
1658 when writing.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1659 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, 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
1660 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1661 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1662 static int val = octave_o_trunc_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1663
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1664 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1665 err_disabled_feature ("O_TRUNC", "O_TRUNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1666
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1667 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
1668 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1669
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1670 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
1671 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
1672 @deftypefn {} {} O_WRONLY ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1673 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
1674
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1675 @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
1676 @code{fcntl} to indicate that a file is open for writing only
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1677 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21949
diff changeset
1678 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1679 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1680 static int val = octave_o_wronly_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1681
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1682 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1683 err_disabled_feature ("O_WRONLY", "O_WRONLY");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1684
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1685 return const_value (args, val);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1686 }
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 3360
diff changeset
1687
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1688 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
1689 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
1690 @deftypefn {} {} WNOHANG ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1691 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
1692
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1693 @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
1694 @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
1695 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
1696 @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
1697 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1698 {
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1699 return const_value (args, octave::sys::wnohang ());
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1700 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1701
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1702 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
1703 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
1704 @deftypefn {} {} WUNTRACED ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1705 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
1706
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1707 @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
1708 @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
1709 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
1710 @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
1711 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
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 return const_value (args, octave::sys::wuntraced ());
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1714 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1715
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1716 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
1717 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
1718 @deftypefn {} {} WCONTINUE ()
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1719 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
1720
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1721 @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
1722 @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
1723 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
1724 @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
1725 @end deftypefn */)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1726 {
21921
ecfcc8527661 hide sys/wait.h header and provide wrappers for waitpid macros
John W. Eaton <jwe@octave.org>
parents: 21911
diff changeset
1727 return const_value (args, octave::sys::wcontinue ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1728 }