Mercurial > hg > octave-lyh
annotate libinterp/corefcn/syscalls.cc @ 17289:bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Macro handles options ("on") or properties ("position") more elegantly
than @code{"text"}.
* doc/interpreter/macros.texi: Add new @qcode macro.
* doc/interpreter/tips.txi: Add documentation about @qcode macro.
* doc/interpreter/basics.txi, doc/interpreter/container.txi,
doc/interpreter/emacs.txi, doc/interpreter/errors.txi,
doc/interpreter/eval.txi, doc/interpreter/expr.txi,
doc/interpreter/external.txi, doc/interpreter/func.txi,
doc/interpreter/grammar.txi, doc/interpreter/image.txi,
doc/interpreter/install.txi, doc/interpreter/interp.txi,
doc/interpreter/io.txi, doc/interpreter/matrix.txi,
doc/interpreter/numbers.txi, doc/interpreter/oop.txi,
doc/interpreter/package.txi, doc/interpreter/plot.txi,
doc/interpreter/quad.txi, doc/interpreter/sparse.txi,
doc/interpreter/strings.txi, doc/interpreter/system.txi,
doc/interpreter/vectorize.txi, libinterp/corefcn/balance.cc,
libinterp/corefcn/bitfcns.cc, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/conv2.cc, libinterp/corefcn/data.cc,
libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc,
libinterp/corefcn/dirfns.cc, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/graphics.cc, libinterp/corefcn/help.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc,
libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lu.cc,
libinterp/corefcn/luinc.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/oct-hist.cc, libinterp/corefcn/pager.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/spparms.cc, libinterp/corefcn/str2double.cc,
libinterp/corefcn/svd.cc, libinterp/corefcn/symtab.cc,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/toplev.cc,
libinterp/corefcn/tril.cc, libinterp/corefcn/typecast.cc,
libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc,
libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/oct-parse.in.yy,
libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-mat.cc, scripts/@ftp/ftp.m,
scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m,
scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/shell_cmd.m,
scripts/general/dblquad.m, scripts/general/display.m,
scripts/general/genvarname.m, scripts/general/idivide.m,
scripts/general/interp1.m, scripts/general/interp2.m,
scripts/general/interp3.m, scripts/general/interpn.m, scripts/general/isa.m,
scripts/general/profexplore.m, scripts/general/profile.m,
scripts/general/quadgk.m, scripts/general/randi.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/triplequad.m,
scripts/geometry/griddata.m, scripts/geometry/griddata3.m,
scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/help/help.m,
scripts/help/lookfor.m, scripts/image/cmpermute.m, scripts/image/colormap.m,
scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m,
scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m,
scripts/image/imwrite.m, scripts/image/ind2gray.m, scripts/image/lines.m,
scripts/image/rgb2ind.m, scripts/image/spinmap.m, scripts/io/dlmwrite.m,
scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m,
scripts/java/javaclasspath.m, scripts/java/usejava.m,
scripts/miscellaneous/bzip2.m, scripts/miscellaneous/computer.m,
scripts/miscellaneous/copyfile.m, scripts/miscellaneous/debug.m,
scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m,
scripts/miscellaneous/gzip.m, scripts/miscellaneous/license.m,
scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m,
scripts/miscellaneous/parseparams.m, scripts/miscellaneous/unix.m,
scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m,
scripts/optimization/fminunc.m, scripts/optimization/fsolve.m,
scripts/optimization/fzero.m, scripts/optimization/glpk.m,
scripts/optimization/lsqnonneg.m, scripts/optimization/optimset.m,
scripts/optimization/pqpnonneg.m, scripts/pkg/pkg.m, scripts/plot/allchild.m,
scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axis.m,
scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m,
scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m,
scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/colorbar.m,
scripts/plot/daspect.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m,
scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/findall.m,
scripts/plot/findobj.m, scripts/plot/gcbo.m, scripts/plot/gcf.m,
scripts/plot/gco.m, scripts/plot/grid.m, scripts/plot/guihandles.m,
scripts/plot/hdl2struct.m, scripts/plot/hidden.m, scripts/plot/hold.m,
scripts/plot/isonormals.m, scripts/plot/isosurface.m, scripts/plot/legend.m,
scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m,
scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m,
scripts/plot/patch.m, scripts/plot/pbaspect.m, scripts/plot/pcolor.m,
scripts/plot/plot.m, scripts/plot/print.m,
scripts/plot/private/__add_default_menu__.m, scripts/plot/quiver.m,
scripts/plot/quiver3.m, scripts/plot/refreshdata.m, scripts/plot/saveas.m,
scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/shading.m,
scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/stem.m,
scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m,
scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m,
scripts/plot/tetramesh.m, scripts/plot/uigetfile.m, scripts/plot/uimenu.m,
scripts/plot/uiputfile.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m,
scripts/plot/xlim.m, scripts/plot/ylim.m, scripts/plot/zlim.m,
scripts/polynomial/conv.m, scripts/polynomial/polyout.m,
scripts/polynomial/splinefit.m, scripts/set/ismember.m, scripts/set/powerset.m,
scripts/set/setdiff.m, scripts/set/union.m, scripts/set/unique.m,
scripts/signal/detrend.m, scripts/signal/filter2.m, scripts/signal/freqz.m,
scripts/signal/periodogram.m, scripts/signal/spectral_adf.m,
scripts/signal/spectral_xdf.m, scripts/sparse/eigs.m, scripts/sparse/svds.m,
scripts/specfun/legendre.m, scripts/special-matrix/gallery.m,
scripts/statistics/base/mean.m, scripts/statistics/base/moment.m,
scripts/statistics/tests/cor_test.m,
scripts/statistics/tests/kolmogorov_smirnov_test.m,
scripts/statistics/tests/kolmogorov_smirnov_test_2.m,
scripts/statistics/tests/kruskal_wallis_test.m,
scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/sign_test.m,
scripts/statistics/tests/t_test.m, scripts/statistics/tests/t_test_2.m,
scripts/statistics/tests/t_test_regression.m,
scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m,
scripts/statistics/tests/welch_test.m,
scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m,
scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m,
scripts/strings/index.m, scripts/strings/isstrprop.m,
scripts/strings/mat2str.m, scripts/strings/regexptranslate.m,
scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m,
scripts/strings/strjust.m, scripts/strings/strmatch.m,
scripts/strings/validatestring.m, scripts/testfun/demo.m,
scripts/testfun/example.m, scripts/testfun/test.m, scripts/time/addtodate.m,
scripts/time/asctime.m, scripts/time/datestr.m, scripts/time/datetick.m,
scripts/time/weekday.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m,
scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m,
scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use new @qcode macro.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 19 Aug 2013 20:46:38 -0700 |
parents | 6a6e3f1a824c |
children | 0bf2fc8562c9 |
rev | line source |
---|---|
2075 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14111
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10336
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
2075 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2075 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2075 | 21 |
22 */ | |
23 | |
24 // Thomas Baier <baier@ci.tuwien.ac.at> added the original versions of | |
25 // the following functions: | |
26 // | |
27 // mkfifo unlink waitpid | |
28 | |
29 #ifdef HAVE_CONFIG_H | |
30 #include <config.h> | |
31 #endif | |
32 | |
33 #include <cstdio> | |
2669 | 34 #include <cstring> |
2075 | 35 |
36 #include <sys/types.h> | |
37 #include <unistd.h> | |
38 | |
39 #include <fcntl.h> | |
40 | |
17244
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
41 #include "cmd-hist.h" |
2926 | 42 #include "file-ops.h" |
43 #include "file-stat.h" | |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
44 #include "oct-env.h" |
2937 | 45 #include "oct-syscalls.h" |
5547 | 46 #include "oct-uname.h" |
2926 | 47 |
2075 | 48 #include "defun.h" |
49 #include "error.h" | |
2078 | 50 #include "gripes.h" |
2075 | 51 #include "lo-utils.h" |
17244
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
52 #include "oct-hist.h" |
2075 | 53 #include "oct-map.h" |
54 #include "oct-obj.h" | |
55 #include "oct-stdstrm.h" | |
56 #include "oct-stream.h" | |
57 #include "sysdep.h" | |
58 #include "utils.h" | |
2366 | 59 #include "variables.h" |
6321 | 60 #include "input.h" |
2075 | 61 |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
62 static octave_scalar_map |
8549 | 63 mk_stat_map (const base_file_stat& fs) |
2075 | 64 { |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
65 octave_scalar_map m; |
2075 | 66 |
4675 | 67 m.assign ("dev", static_cast<double> (fs.dev ())); |
68 m.assign ("ino", fs.ino ()); | |
5476 | 69 m.assign ("mode", fs.mode ()); |
4675 | 70 m.assign ("modestr", fs.mode_as_string ()); |
71 m.assign ("nlink", fs.nlink ()); | |
72 m.assign ("uid", fs.uid ()); | |
73 m.assign ("gid", fs.gid ()); | |
3887 | 74 #if defined (HAVE_STRUCT_STAT_ST_RDEV) |
4675 | 75 m.assign ("rdev", static_cast<double> (fs.rdev ())); |
2075 | 76 #endif |
4675 | 77 m.assign ("size", fs.size ()); |
78 m.assign ("atime", fs.atime ()); | |
79 m.assign ("mtime", fs.mtime ()); | |
80 m.assign ("ctime", fs.ctime ()); | |
3887 | 81 #if defined (HAVE_STRUCT_STAT_ST_BLKSIZE) |
4675 | 82 m.assign ("blksize", fs.blksize ()); |
2075 | 83 #endif |
3887 | 84 #if defined (HAVE_STRUCT_STAT_ST_BLOCKS) |
4675 | 85 m.assign ("blocks", fs.blocks ()); |
2075 | 86 #endif |
87 | |
88 return m; | |
89 } | |
90 | |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
91 static octave_value_list |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
92 mk_stat_result (const base_file_stat& fs) |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
93 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
94 octave_value_list retval; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
95 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
96 if (fs) |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
97 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
98 retval(2) = std::string (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
99 retval(1) = 0; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
100 retval(0) = octave_value (mk_stat_map (fs)); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
101 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
102 else |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
103 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
104 retval(2) = fs.error (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
105 retval(1) = -1; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
106 retval(0) = Matrix (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
107 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
108 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
109 return retval; |
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 |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
112 DEFUNX ("dup2", Fdup2, args, , |
3301 | 113 "-*- texinfo -*-\n\ |
114 @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})\n\ | |
2669 | 115 Duplicate a file descriptor.\n\ |
116 \n\ | |
3301 | 117 If successful, @var{fid} is greater than zero and contains the new file\n\ |
10840 | 118 ID@. Otherwise, @var{fid} is negative and @var{msg} contains a\n\ |
3301 | 119 system-dependent error message.\n\ |
120 @end deftypefn") | |
2075 | 121 { |
2669 | 122 octave_value_list retval; |
123 | |
3523 | 124 retval(1) = std::string (); |
4294 | 125 retval(0) = -1; |
2075 | 126 |
127 int nargin = args.length (); | |
128 | |
129 if (nargin == 2) | |
130 { | |
3341 | 131 octave_stream old_stream |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
132 = octave_stream_list::lookup (args(0), "dup2"); |
2075 | 133 |
3341 | 134 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
135 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
136 octave_stream new_stream |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
137 = octave_stream_list::lookup (args(1), "dup2"); |
2075 | 138 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
139 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
140 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
141 int i_old = old_stream.file_number (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
142 int i_new = new_stream.file_number (); |
2937 | 143 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
144 if (i_old >= 0 && i_new >= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
145 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
146 std::string msg; |
2669 | 147 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
148 int status = octave_syscalls::dup2 (i_old, i_new, msg); |
3341 | 149 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
150 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
151 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
152 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
153 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
154 } |
3145 | 155 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
156 error ("dup2: invalid stream"); |
2075 | 157 } |
158 else | |
5823 | 159 print_usage (); |
2075 | 160 |
161 return retval; | |
162 } | |
163 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
164 DEFUNX ("exec", Fexec, args, , |
3301 | 165 "-*- texinfo -*-\n\ |
166 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} exec (@var{file}, @var{args})\n\ | |
167 Replace current process with a new process. Calling @code{exec} without\n\ | |
168 first calling @code{fork} will terminate your current Octave process and\n\ | |
169 replace it with the program named by @var{file}. For example,\n\ | |
2669 | 170 \n\ |
3301 | 171 @example\n\ |
172 exec (\"ls\" \"-l\")\n\ | |
173 @end example\n\ | |
2669 | 174 \n\ |
3301 | 175 @noindent\n\ |
176 will run @code{ls} and return you to your shell prompt.\n\ | |
177 \n\ | |
178 If successful, @code{exec} does not return. If @code{exec} does return,\n\ | |
179 @var{err} will be nonzero, and @var{msg} will contain a system-dependent\n\ | |
180 error message.\n\ | |
181 @end deftypefn") | |
2075 | 182 { |
2669 | 183 octave_value_list retval; |
184 | |
3523 | 185 retval(1) = std::string (); |
4294 | 186 retval(0) = -1; |
2075 | 187 |
188 int nargin = args.length (); | |
189 | |
190 if (nargin == 1 || nargin == 2) | |
191 { | |
3523 | 192 std::string exec_file = args(0).string_value (); |
2075 | 193 |
194 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
195 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
196 string_vector exec_args; |
2075 | 197 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
198 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
199 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
200 string_vector tmp = args(1).all_strings (); |
2075 | 201 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
202 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
203 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
204 int len = tmp.length (); |
2075 | 205 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
206 exec_args.resize (len + 1); |
2075 | 207 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
208 exec_args[0] = exec_file; |
2075 | 209 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
210 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
211 exec_args[i+1] = tmp[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
212 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
213 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
214 error ("exec: arguments must be character strings"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
215 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
216 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
217 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
218 exec_args.resize (1); |
2075 | 219 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
220 exec_args[0] = exec_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
221 } |
2075 | 222 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
223 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
224 { |
17244
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
225 octave_history_write_timestamp (); |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
226 |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
227 if (! command_history::ignoring_entries ()) |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
228 command_history::clean_up_and_save (); |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
229 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
230 std::string msg; |
2937 | 231 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
232 int status = octave_syscalls::execvp (exec_file, exec_args, msg); |
2669 | 233 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
234 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
235 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
236 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
237 } |
2075 | 238 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
239 error ("exec: FILE must be a string"); |
2075 | 240 } |
241 else | |
5823 | 242 print_usage (); |
2075 | 243 |
244 return retval; | |
245 } | |
246 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
247 DEFUNX ("popen2", Fpopen2, args, , |
6321 | 248 "-*- texinfo -*-\n\ |
6678 | 249 @deftypefn {Built-in Function} {[@var{in}, @var{out}, @var{pid}] =} popen2 (@var{command}, @var{args})\n\ |
6321 | 250 Start a subprocess with two-way communication. The name of the process\n\ |
251 is given by @var{command}, and @var{args} is an array of strings\n\ | |
252 containing options for the command. The file identifiers for the input\n\ | |
253 and output streams of the subprocess are returned in @var{in} and\n\ | |
254 @var{out}. If execution of the command is successful, @var{pid}\n\ | |
255 contains the process ID of the subprocess. Otherwise, @var{pid} is\n\ | |
256 @minus{}1.\n\ | |
257 \n\ | |
10840 | 258 For example:\n\ |
6321 | 259 \n\ |
260 @example\n\ | |
6923 | 261 [in, out, pid] = popen2 (\"sort\", \"-r\");\n\ |
6321 | 262 fputs (in, \"these\\nare\\nsome\\nstrings\\n\");\n\ |
263 fclose (in);\n\ | |
264 EAGAIN = errno (\"EAGAIN\");\n\ | |
265 done = false;\n\ | |
266 do\n\ | |
267 s = fgets (out);\n\ | |
268 if (ischar (s))\n\ | |
269 fputs (stdout, s);\n\ | |
270 elseif (errno () == EAGAIN)\n\ | |
271 sleep (0.1);\n\ | |
272 fclear (out);\n\ | |
273 else\n\ | |
274 done = true;\n\ | |
275 endif\n\ | |
276 until (done)\n\ | |
277 fclose (out);\n\ | |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
278 waitpid (pid);\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
279 \n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
280 @print{} these\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
281 @print{} strings\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
282 @print{} some\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
283 @print{} are\n\ |
6321 | 284 @end example\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
285 \n\ |
17289
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17244
diff
changeset
|
286 Note that @code{popen2}, unlike @code{popen}, will not @qcode{\"reap\"} the\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
287 child process. If you don't use @code{waitpid} to check the child's\n\ |
9564 | 288 exit status, it will linger until Octave exits.\n\ |
6321 | 289 @end deftypefn") |
290 { | |
291 octave_value_list retval; | |
292 | |
293 retval(2) = -1; | |
294 retval(1) = Matrix (); | |
295 retval(0) = Matrix (); | |
296 | |
297 int nargin = args.length (); | |
298 | |
299 if (nargin >= 1 && nargin <= 3) | |
300 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14819
diff
changeset
|
301 std::string exec_file = args(0).string_value (); |
6321 | 302 |
303 if (! error_state) | |
304 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
305 string_vector arg_list; |
6321 | 306 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
307 if (nargin >= 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
308 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
309 string_vector tmp = args(1).all_strings (); |
6321 | 310 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
311 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
312 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
313 int len = tmp.length (); |
6321 | 314 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
315 arg_list.resize (len + 1); |
6321 | 316 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
317 arg_list[0] = exec_file; |
6321 | 318 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
319 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
320 arg_list[i+1] = tmp[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
321 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
322 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
323 error ("popen2: arguments must be character strings"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
324 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
325 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
326 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
327 arg_list.resize (1); |
6321 | 328 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
329 arg_list[0] = exec_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
330 } |
6321 | 331 |
332 if (! error_state) | |
333 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14819
diff
changeset
|
334 bool sync_mode = (nargin == 3 ? args(2).bool_value () : false); |
6321 | 335 |
336 if (! error_state) | |
337 { | |
338 int fildes[2]; | |
339 std::string msg; | |
340 pid_t pid; | |
341 | |
342 pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode, fildes, msg, interactive); | |
343 if (pid >= 0) | |
344 { | |
345 FILE *ifile = fdopen (fildes[1], "r"); | |
346 FILE *ofile = fdopen (fildes[0], "w"); | |
347 | |
348 std::string nm; | |
349 | |
350 octave_stream is = octave_stdiostream::create (nm, ifile, | |
351 std::ios::in); | |
352 | |
353 octave_stream os = octave_stdiostream::create (nm, ofile, | |
354 std::ios::out); | |
355 | |
356 Cell file_ids (1, 2); | |
357 | |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
358 retval(2) = pid; |
6321 | 359 retval(1) = octave_stream_list::insert (is); |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
360 retval(0) = octave_stream_list::insert (os); |
6321 | 361 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
362 else |
6321 | 363 error (msg.c_str ()); |
364 } | |
365 } | |
366 else | |
367 error ("popen2: arguments must be character strings"); | |
368 } | |
369 else | |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
370 error ("popen2: COMMAND argument must be a string"); |
6321 | 371 } |
372 else | |
373 print_usage (); | |
374 | |
375 return retval; | |
376 } | |
377 | |
378 /* | |
379 %!test | |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
380 %! if (isunix ()) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
381 %! [in, out, pid] = popen2 ("sort", "-r"); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
382 %! EAGAIN = errno ("EAGAIN"); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
383 %! else |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
384 %! [in, out, pid] = popen2 ("sort", "/R"); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
385 %! EAGAIN = errno ("EINVAL"); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
386 %! endif |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
387 %! fputs (in, "these\nare\nsome\nstrings\n"); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
388 %! fclose (in); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
389 %! done = false; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
390 %! str = {}; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
391 %! idx = 0; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
392 %! errs = 0; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
393 %! do |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
394 %! if (!isunix ()) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
395 %! errno (0); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
396 %! endif |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
397 %! s = fgets (out); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
398 %! if (ischar (s)) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
399 %! idx++; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
400 %! str{idx} = s; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
401 %! elseif (errno () == EAGAIN) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
402 %! fclear (out); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
403 %! sleep (0.1); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
404 %! if (++errs == 100) |
6321 | 405 %! done = true; |
406 %! endif | |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
407 %! else |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
408 %! done = true; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
409 %! endif |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
410 %! until (done) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
411 %! fclose (out); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
412 %! if (isunix ()) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
413 %! assert (str, {"these\n","strings\n","some\n","are\n"}); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
414 %! else |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
415 %! 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
|
416 %! endif |
6321 | 417 */ |
418 | |
10259 | 419 DEFUNX ("fcntl", Ffcntl, args, , |
3301 | 420 "-*- texinfo -*-\n\ |
421 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})\n\ | |
422 Change the properties of the open file @var{fid}. The following values\n\ | |
423 may be passed as @var{request}:\n\ | |
424 \n\ | |
425 @vtable @code\n\ | |
426 @item F_DUPFD\n\ | |
427 Return a duplicate file descriptor.\n\ | |
428 \n\ | |
429 @item F_GETFD\n\ | |
430 Return the file descriptor flags for @var{fid}.\n\ | |
431 \n\ | |
432 @item F_SETFD\n\ | |
433 Set the file descriptor flags for @var{fid}.\n\ | |
434 \n\ | |
435 @item F_GETFL\n\ | |
436 Return the file status flags for @var{fid}. The following codes may be\n\ | |
437 returned (some of the flags may be undefined on some systems).\n\ | |
438 \n\ | |
439 @vtable @code\n\ | |
440 @item O_RDONLY\n\ | |
441 Open for reading only.\n\ | |
442 \n\ | |
443 @item O_WRONLY\n\ | |
444 Open for writing only.\n\ | |
2669 | 445 \n\ |
3301 | 446 @item O_RDWR\n\ |
447 Open for reading and writing.\n\ | |
448 \n\ | |
449 @item O_APPEND\n\ | |
450 Append on each write.\n\ | |
451 \n\ | |
5040 | 452 @item O_CREAT\n\ |
453 Create the file if it does not exist.\n\ | |
454 \n\ | |
3301 | 455 @item O_NONBLOCK\n\ |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
10762
diff
changeset
|
456 Non-blocking mode.\n\ |
3301 | 457 \n\ |
458 @item O_SYNC\n\ | |
459 Wait for writes to complete.\n\ | |
2669 | 460 \n\ |
3301 | 461 @item O_ASYNC\n\ |
462 Asynchronous I/O.\n\ | |
463 @end vtable\n\ | |
464 \n\ | |
465 @item F_SETFL\n\ | |
466 Set the file status flags for @var{fid} to the value specified by\n\ | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
467 @var{arg}. The only flags that can be changed are @w{@code{O_APPEND}} and\n\ |
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
468 @w{@code{O_NONBLOCK}}.\n\ |
3301 | 469 @end vtable\n\ |
470 \n\ | |
471 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ | |
472 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
473 system-dependent error message.\n\ | |
474 @end deftypefn") | |
2075 | 475 { |
2669 | 476 octave_value_list retval; |
477 | |
3523 | 478 retval(1) = std::string (); |
4294 | 479 retval(0) = -1; |
2075 | 480 |
481 int nargin = args.length (); | |
482 | |
483 if (nargin == 3) | |
484 { | |
3715 | 485 octave_stream strm = octave_stream_list::lookup (args (0), "fcntl"); |
2075 | 486 |
3202 | 487 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
488 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
489 int fid = strm.file_number (); |
3715 | 490 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
491 int req = args(1).int_value (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
492 int arg = args(2).int_value (true); |
3715 | 493 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
494 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
495 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
496 // FIXME -- Need better checking here? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
497 if (fid < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
498 error ("fcntl: invalid file id"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
499 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
500 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
501 std::string msg; |
2937 | 502 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
503 int status = octave_fcntl (fid, req, arg, msg); |
2669 | 504 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
505 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
506 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
507 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
508 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
509 } |
2075 | 510 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
511 error ("fcntl: FID, REQUEST, and ARG must be integers"); |
2075 | 512 } |
513 else | |
5823 | 514 print_usage (); |
2075 | 515 |
516 return retval; | |
517 } | |
518 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
519 DEFUNX ("fork", Ffork, args, , |
3301 | 520 "-*- texinfo -*-\n\ |
521 @deftypefn {Built-in Function} {[@var{pid}, @var{msg}] =} fork ()\n\ | |
2669 | 522 Create a copy of the current process.\n\ |
523 \n\ | |
3301 | 524 Fork can return one of the following values:\n\ |
525 \n\ | |
526 @table @asis\n\ | |
527 @item > 0\n\ | |
528 You are in the parent process. The value returned from @code{fork} is\n\ | |
529 the process id of the child process. You should probably arrange to\n\ | |
530 wait for any child processes to exit.\n\ | |
531 \n\ | |
532 @item 0\n\ | |
533 You are in the child process. You can call @code{exec} to start another\n\ | |
534 process. If that fails, you should probably call @code{exit}.\n\ | |
535 \n\ | |
536 @item < 0\n\ | |
537 The call to @code{fork} failed for some reason. You must take evasive\n\ | |
538 action. A system dependent error message will be waiting in @var{msg}.\n\ | |
539 @end table\n\ | |
540 @end deftypefn") | |
2075 | 541 { |
2669 | 542 octave_value_list retval; |
543 | |
3523 | 544 retval(1) = std::string (); |
4294 | 545 retval(0) = -1; |
2075 | 546 |
547 int nargin = args.length (); | |
548 | |
549 if (nargin == 0) | |
2475 | 550 { |
3523 | 551 std::string msg; |
2937 | 552 |
553 pid_t pid = octave_syscalls::fork (msg); | |
2669 | 554 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
555 retval(1) = msg; |
4233 | 556 retval(0) = pid; |
2475 | 557 } |
2075 | 558 else |
5823 | 559 print_usage (); |
2075 | 560 |
561 return retval; | |
562 } | |
563 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
564 DEFUNX ("getpgrp", Fgetpgrp, args, , |
3301 | 565 "-*- texinfo -*-\n\ |
566 @deftypefn {Built-in Function} {pgid =} getpgrp ()\n\ | |
567 Return the process group id of the current process.\n\ | |
568 @end deftypefn") | |
2075 | 569 { |
2937 | 570 octave_value_list retval; |
571 | |
3523 | 572 retval(1) = std::string (); |
4294 | 573 retval(0) = -1; |
2075 | 574 |
575 int nargin = args.length (); | |
576 | |
577 if (nargin == 0) | |
2475 | 578 { |
3523 | 579 std::string msg; |
2937 | 580 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
581 retval(1) = msg; |
4233 | 582 retval(0) = octave_syscalls::getpgrp (msg); |
2475 | 583 } |
2075 | 584 else |
5823 | 585 print_usage (); |
2075 | 586 |
587 return retval; | |
588 } | |
589 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
590 DEFUNX ("getpid", Fgetpid, args, , |
3301 | 591 "-*- texinfo -*-\n\ |
592 @deftypefn {Built-in Function} {pid =} getpid ()\n\ | |
593 Return the process id of the current process.\n\ | |
594 @end deftypefn") | |
2075 | 595 { |
4233 | 596 octave_value retval = -1; |
2075 | 597 |
598 int nargin = args.length (); | |
599 | |
600 if (nargin == 0) | |
2937 | 601 retval = octave_syscalls::getpid (); |
2075 | 602 else |
5823 | 603 print_usage (); |
2075 | 604 |
605 return retval; | |
606 } | |
607 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
608 DEFUNX ("getppid", Fgetppid, args, , |
3301 | 609 "-*- texinfo -*-\n\ |
610 @deftypefn {Built-in Function} {pid =} getppid ()\n\ | |
611 Return the process id of the parent process.\n\ | |
612 @end deftypefn") | |
2075 | 613 { |
4233 | 614 octave_value retval = -1; |
2075 | 615 |
2475 | 616 int nargin = args.length (); |
617 | |
618 if (nargin == 0) | |
2937 | 619 retval = octave_syscalls::getppid (); |
2475 | 620 else |
5823 | 621 print_usage (); |
2475 | 622 |
623 return retval; | |
624 } | |
625 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
626 DEFUNX ("getegid", Fgetegid, args, , |
3301 | 627 "-*- texinfo -*-\n\ |
628 @deftypefn {Built-in Function} {egid =} getegid ()\n\ | |
629 Return the effective group id of the current process.\n\ | |
630 @end deftypefn") | |
2475 | 631 { |
4233 | 632 octave_value retval = -1; |
2475 | 633 |
2075 | 634 int nargin = args.length (); |
635 | |
636 if (nargin == 0) | |
4254 | 637 retval = octave_syscalls::getegid (); |
2075 | 638 else |
5823 | 639 print_usage (); |
2475 | 640 |
641 return retval; | |
642 } | |
643 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
644 DEFUNX ("getgid", Fgetgid, args, , |
3301 | 645 "-*- texinfo -*-\n\ |
646 @deftypefn {Built-in Function} {gid =} getgid ()\n\ | |
647 Return the real group id of the current process.\n\ | |
648 @end deftypefn") | |
2475 | 649 { |
4233 | 650 octave_value retval = -1; |
2475 | 651 |
652 int nargin = args.length (); | |
653 | |
654 if (nargin == 0) | |
4254 | 655 retval = octave_syscalls::getgid (); |
2475 | 656 else |
5823 | 657 print_usage (); |
2075 | 658 |
659 return retval; | |
660 } | |
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 ("geteuid", Fgeteuid, args, , |
3301 | 663 "-*- texinfo -*-\n\ |
664 @deftypefn {Built-in Function} {euid =} geteuid ()\n\ | |
665 Return the effective user id of the current process.\n\ | |
666 @end deftypefn") | |
2472 | 667 { |
4233 | 668 octave_value retval = -1; |
2472 | 669 |
670 int nargin = args.length (); | |
671 | |
672 if (nargin == 0) | |
4254 | 673 retval = octave_syscalls::geteuid (); |
2472 | 674 else |
5823 | 675 print_usage (); |
2473 | 676 |
677 return retval; | |
2472 | 678 } |
679 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
680 DEFUNX ("getuid", Fgetuid, args, , |
3301 | 681 "-*- texinfo -*-\n\ |
682 @deftypefn {Built-in Function} {uid =} getuid ()\n\ | |
683 Return the real user id of the current process.\n\ | |
684 @end deftypefn") | |
2472 | 685 { |
4233 | 686 octave_value retval = -1; |
2472 | 687 |
688 int nargin = args.length (); | |
689 | |
690 if (nargin == 0) | |
4254 | 691 retval = octave_syscalls::getuid (); |
2472 | 692 else |
5823 | 693 print_usage (); |
2473 | 694 |
695 return retval; | |
2472 | 696 } |
697 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
698 DEFUNX ("kill", Fkill, args, , |
4371 | 699 "-*- texinfo -*-\n\ |
4294 | 700 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} kill (@var{pid}, @var{sig})\n\ |
701 Send signal @var{sig} to process @var{pid}.\n\ | |
702 \n\ | |
703 If @var{pid} is positive, then signal @var{sig} is sent to @var{pid}.\n\ | |
704 \n\ | |
705 If @var{pid} is 0, then signal @var{sig} is sent to every process\n\ | |
706 in the process group of the current process.\n\ | |
707 \n\ | |
708 If @var{pid} is -1, then signal @var{sig} is sent to every process\n\ | |
709 except process 1.\n\ | |
710 \n\ | |
711 If @var{pid} is less than -1, then signal @var{sig} is sent to every\n\ | |
712 process in the process group @var{-pid}.\n\ | |
713 \n\ | |
4371 | 714 If @var{sig} is 0, then no signal is sent, but error checking is still\n\ |
4294 | 715 performed.\n\ |
716 \n\ | |
7001 | 717 Return 0 if successful, otherwise return -1.\n\ |
4294 | 718 @end deftypefn") |
719 { | |
720 octave_value_list retval; | |
721 | |
722 retval(1) = std::string (); | |
723 retval(0) = -1; | |
724 | |
725 if (args.length () == 2) | |
726 { | |
727 pid_t pid = args(0).int_value (true); | |
728 | |
729 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
730 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
731 int sig = args(1).int_value (true); |
4294 | 732 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
733 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
734 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
735 std::string msg; |
4294 | 736 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
737 int status = octave_syscalls::kill (pid, sig, msg); |
4294 | 738 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
739 retval(1) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
740 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
741 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
742 } |
4294 | 743 } |
744 else | |
5823 | 745 print_usage (); |
4294 | 746 |
747 return retval; | |
748 } | |
749 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
750 DEFUNX ("lstat", Flstat, args, , |
3458 | 751 "-*- texinfo -*-\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
752 @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
753 Return a structure @var{info} containing information about the symbolic link\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
754 @var{symlink}. The function outputs are described in the documentation for\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
755 @code{stat}.\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
756 @seealso{stat}\n\ |
3458 | 757 @end deftypefn") |
2075 | 758 { |
2263 | 759 octave_value_list retval; |
2075 | 760 |
761 if (args.length () == 1) | |
762 { | |
5872 | 763 std::string fname = args(0).string_value (); |
2075 | 764 |
765 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
766 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
767 file_stat fs (fname, false); |
2075 | 768 |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
769 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
770 } |
2075 | 771 } |
772 else | |
5823 | 773 print_usage (); |
2075 | 774 |
775 return retval; | |
776 } | |
777 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
778 DEFUNX ("mkfifo", Fmkfifo, args, , |
3345 | 779 "-*- texinfo -*-\n\ |
4825 | 780 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ |
4928 | 781 Create a @var{fifo} special file named @var{name} with file mode @var{mode}\n\ |
2075 | 782 \n\ |
3301 | 783 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
784 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
785 system-dependent error message.\n\ | |
786 @end deftypefn") | |
2075 | 787 { |
2669 | 788 octave_value_list retval; |
789 | |
3523 | 790 retval(1) = std::string (); |
4294 | 791 retval(0) = -1; |
2075 | 792 |
793 int nargin = args.length (); | |
794 | |
795 if (nargin == 2) | |
796 { | |
797 if (args(0).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
798 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
799 std::string name = args(0).string_value (); |
2075 | 800 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
801 if (args(1).is_scalar_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
802 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
803 long mode = args(1).long_value (); |
2075 | 804 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
805 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
806 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
807 std::string msg; |
4254 | 808 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
809 int status = octave_mkfifo (name, mode, msg); |
2669 | 810 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
811 retval(0) = status; |
2669 | 812 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
813 if (status < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
814 retval(1) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
815 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
816 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
817 error ("mkfifo: invalid MODE"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
818 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
819 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
820 error ("mkfifo: MODE must be an integer"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
821 } |
2075 | 822 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
823 error ("mkfifo: FILE must be a string"); |
2075 | 824 } |
825 else | |
5823 | 826 print_usage (); |
2075 | 827 |
828 return retval; | |
829 } | |
830 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
831 DEFUNX ("pipe", Fpipe, args, , |
3301 | 832 "-*- texinfo -*-\n\ |
6321 | 833 @deftypefn {Built-in Function} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\ |
834 Create a pipe and return the reading and writing ends of the pipe\n\ | |
835 into @var{read_fd} and @var{write_fd} respectively.\n\ | |
2669 | 836 \n\ |
3301 | 837 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
838 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
839 system-dependent error message.\n\ | |
840 @end deftypefn") | |
2075 | 841 { |
2669 | 842 octave_value_list retval; |
843 | |
6321 | 844 retval(3) = std::string (); |
845 retval(2) = -1; | |
4294 | 846 retval(1) = -1; |
6321 | 847 retval(0) = -1; |
2075 | 848 |
849 int nargin = args.length (); | |
850 | |
851 if (nargin == 0) | |
852 { | |
853 int fid[2]; | |
854 | |
3523 | 855 std::string msg; |
2937 | 856 |
857 int status = octave_syscalls::pipe (fid, msg); | |
2669 | 858 |
859 if (status < 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
860 retval(3) = msg; |
2669 | 861 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
862 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
863 FILE *ifile = fdopen (fid[0], "r"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
864 FILE *ofile = fdopen (fid[1], "w"); |
2075 | 865 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
866 std::string nm; |
4327 | 867 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
868 octave_stream is = octave_stdiostream::create (nm, ifile, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
869 std::ios::in); |
4327 | 870 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
871 octave_stream os = octave_stdiostream::create (nm, ofile, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
872 std::ios::out); |
2075 | 873 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
874 retval(2) = status; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
875 retval(1) = octave_stream_list::insert (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
876 retval(0) = octave_stream_list::insert (is); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
877 } |
2075 | 878 } |
879 else | |
5823 | 880 print_usage (); |
2075 | 881 |
882 return retval; | |
883 } | |
884 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
885 DEFUNX ("stat", Fstat, args, , |
3301 | 886 "-*- texinfo -*-\n\ |
10840 | 887 @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{file})\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
888 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{fid})\n\ |
3301 | 889 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{file})\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
890 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{fid})\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
891 Return a structure @var{info} containing the following information about\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
892 @var{file} or file identifier @var{fid}.\n\ |
3301 | 893 \n\ |
894 @table @code\n\ | |
895 @item dev\n\ | |
896 ID of device containing a directory entry for this file.\n\ | |
897 \n\ | |
898 @item ino\n\ | |
899 File number of the file.\n\ | |
900 \n\ | |
5476 | 901 @item mode\n\ |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
902 File mode, as an integer. Use the functions @w{@code{S_ISREG}},\n\ |
17289
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17244
diff
changeset
|
903 @w{@code{S_ISDIR}}, @w{@code{S_ISCHR}}, @w{@code{S_ISBLK}},\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17244
diff
changeset
|
904 @w{@code{S_ISFIFO}}, @w{@code{S_ISLNK}}, or @w{@code{S_ISSOCK}} to extract\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17244
diff
changeset
|
905 information from this value.\n\ |
5476 | 906 \n\ |
3301 | 907 @item modestr\n\ |
908 File mode, as a string of ten letters or dashes as would be returned by\n\ | |
909 @kbd{ls -l}.\n\ | |
910 \n\ | |
911 @item nlink\n\ | |
912 Number of links.\n\ | |
2075 | 913 \n\ |
3301 | 914 @item uid\n\ |
915 User ID of file's owner.\n\ | |
916 \n\ | |
917 @item gid\n\ | |
918 Group ID of file's group.\n\ | |
919 \n\ | |
920 @item rdev\n\ | |
921 ID of device for block or character special files.\n\ | |
922 \n\ | |
923 @item size\n\ | |
924 Size in bytes.\n\ | |
925 \n\ | |
926 @item atime\n\ | |
927 Time of last access in the same form as time values returned from\n\ | |
928 @code{time}. @xref{Timing Utilities}.\n\ | |
929 \n\ | |
930 @item mtime\n\ | |
931 Time of last modification in the same form as time values returned from\n\ | |
932 @code{time}. @xref{Timing Utilities}.\n\ | |
2075 | 933 \n\ |
3301 | 934 @item ctime\n\ |
935 Time of last file status change in the same form as time values\n\ | |
936 returned from @code{time}. @xref{Timing Utilities}.\n\ | |
937 \n\ | |
938 @item blksize\n\ | |
939 Size of blocks in the file.\n\ | |
940 \n\ | |
941 @item blocks\n\ | |
942 Number of blocks allocated for file.\n\ | |
943 @end table\n\ | |
944 \n\ | |
945 If the call is successful @var{err} is 0 and @var{msg} is an empty\n\ | |
15065
f7215831fe78
doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents:
14861
diff
changeset
|
946 string. If the file does not exist, or some other error occurs, @var{info}\n\ |
3301 | 947 is an empty matrix, @var{err} is @minus{}1, and @var{msg} contains the\n\ |
948 corresponding system error message.\n\ | |
949 \n\ | |
950 If @var{file} is a symbolic link, @code{stat} will return information\n\ | |
7001 | 951 about the actual file that is referenced by the link. Use @code{lstat}\n\ |
3301 | 952 if you want information about the symbolic link itself.\n\ |
953 \n\ | |
10840 | 954 For example:\n\ |
2075 | 955 \n\ |
3301 | 956 @example\n\ |
15065
f7215831fe78
doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents:
14861
diff
changeset
|
957 [info, err, msg] = stat (\"/vmlinuz\")\n\ |
f7215831fe78
doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents:
14861
diff
changeset
|
958 @result{} info =\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
959 @{\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
960 atime = 855399756\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
961 rdev = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
962 ctime = 847219094\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
963 uid = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
964 size = 389218\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
965 blksize = 4096\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
966 mtime = 847219094\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
967 gid = 6\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
968 nlink = 1\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
969 blocks = 768\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
970 mode = -rw-r--r--\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
971 modestr = -rw-r--r--\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
972 ino = 9316\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
973 dev = 2049\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
974 @}\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
975 @result{} err = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
976 @result{} msg =\n\ |
3301 | 977 @end example\n\ |
978 @end deftypefn") | |
2075 | 979 { |
2262 | 980 octave_value_list retval; |
2075 | 981 |
982 if (args.length () == 1) | |
983 { | |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
984 if (args(0).is_scalar_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
985 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
986 int fid = octave_stream_list::get_file_number (args(0)); |
2075 | 987 |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
988 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
989 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
990 file_fstat fs (fid); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
991 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
992 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
993 } |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
994 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
995 else |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
996 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
997 std::string fname = args(0).string_value (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
998 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
999 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1000 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1001 file_stat fs (fname); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1002 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1003 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1004 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1005 } |
2075 | 1006 } |
1007 else | |
5823 | 1008 print_usage (); |
2075 | 1009 |
1010 return retval; | |
1011 } | |
1012 | |
5476 | 1013 DEFUNX ("S_ISREG", FS_ISREG, args, , |
1014 "-*- texinfo -*-\n\ | |
1015 @deftypefn {Built-in Function} {} S_ISREG (@var{mode})\n\ | |
1016 Return true if @var{mode} corresponds to a regular file. The value\n\ | |
1017 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1018 @seealso{stat, lstat}\n\ | |
1019 @end deftypefn") | |
1020 { | |
1021 octave_value retval = false; | |
1022 | |
1023 if (args.length () == 1) | |
1024 { | |
1025 double mode = args(0).double_value (); | |
1026 | |
1027 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1028 retval = file_stat::is_reg (static_cast<mode_t> (mode)); |
5476 | 1029 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1030 error ("S_ISREG: invalid MODE value"); |
5476 | 1031 } |
1032 else | |
5823 | 1033 print_usage (); |
5476 | 1034 |
1035 return retval; | |
1036 } | |
1037 | |
1038 DEFUNX ("S_ISDIR", FS_ISDIR, args, , | |
1039 "-*- texinfo -*-\n\ | |
1040 @deftypefn {Built-in Function} {} S_ISDIR (@var{mode})\n\ | |
1041 Return true if @var{mode} corresponds to a directory. The value\n\ | |
1042 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1043 @seealso{stat, lstat}\n\ | |
1044 @end deftypefn") | |
1045 { | |
1046 octave_value retval = false; | |
1047 | |
1048 if (args.length () == 1) | |
1049 { | |
1050 double mode = args(0).double_value (); | |
1051 | |
1052 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1053 retval = file_stat::is_dir (static_cast<mode_t> (mode)); |
5476 | 1054 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1055 error ("S_ISDIR: invalid MODE value"); |
5476 | 1056 } |
1057 else | |
5823 | 1058 print_usage (); |
5476 | 1059 |
1060 return retval; | |
1061 } | |
1062 | |
1063 DEFUNX ("S_ISCHR", FS_ISCHR, args, , | |
1064 "-*- texinfo -*-\n\ | |
1065 @deftypefn {Built-in Function} {} S_ISCHR (@var{mode})\n\ | |
12212
f1ab2a12b4f4
Add S_ISSOCK function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
1066 Return true if @var{mode} corresponds to a character device. The value\n\ |
5476 | 1067 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
1068 @seealso{stat, lstat}\n\ | |
1069 @end deftypefn") | |
1070 { | |
1071 octave_value retval = false; | |
1072 | |
1073 if (args.length () == 1) | |
1074 { | |
1075 double mode = args(0).double_value (); | |
1076 | |
1077 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1078 retval = file_stat::is_chr (static_cast<mode_t> (mode)); |
5476 | 1079 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1080 error ("S_ISCHR: invalid MODE value"); |
5476 | 1081 } |
1082 else | |
5823 | 1083 print_usage (); |
5476 | 1084 |
1085 return retval; | |
1086 } | |
1087 | |
1088 DEFUNX ("S_ISBLK", FS_ISBLK, args, , | |
1089 "-*- texinfo -*-\n\ | |
1090 @deftypefn {Built-in Function} {} S_ISBLK (@var{mode})\n\ | |
1091 Return true if @var{mode} corresponds to a block device. The value\n\ | |
1092 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1093 @seealso{stat, lstat}\n\ | |
1094 @end deftypefn") | |
1095 { | |
1096 octave_value retval = false; | |
1097 | |
1098 if (args.length () == 1) | |
1099 { | |
1100 double mode = args(0).double_value (); | |
1101 | |
1102 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1103 retval = file_stat::is_blk (static_cast<mode_t> (mode)); |
5476 | 1104 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1105 error ("S_ISBLK: invalid MODE value"); |
5476 | 1106 } |
1107 else | |
5823 | 1108 print_usage (); |
5476 | 1109 |
1110 return retval; | |
1111 } | |
1112 | |
1113 DEFUNX ("S_ISFIFO", FS_ISFIFO, args, , | |
1114 "-*- texinfo -*-\n\ | |
1115 @deftypefn {Built-in Function} {} S_ISFIFO (@var{mode})\n\ | |
1116 Return true if @var{mode} corresponds to a fifo. The value\n\ | |
1117 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1118 @seealso{stat, lstat}\n\ | |
1119 @end deftypefn") | |
1120 { | |
1121 octave_value retval = false; | |
1122 | |
1123 if (args.length () == 1) | |
1124 { | |
1125 double mode = args(0).double_value (); | |
1126 | |
1127 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1128 retval = file_stat::is_fifo (static_cast<mode_t> (mode)); |
5476 | 1129 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1130 error ("S_ISFIFO: invalid MODE value"); |
5476 | 1131 } |
1132 else | |
5823 | 1133 print_usage (); |
5476 | 1134 |
1135 return retval; | |
1136 } | |
1137 | |
1138 DEFUNX ("S_ISLNK", FS_ISLNK, args, , | |
1139 "-*- texinfo -*-\n\ | |
1140 @deftypefn {Built-in Function} {} S_ISLNK (@var{mode})\n\ | |
1141 Return true if @var{mode} corresponds to a symbolic link. The value\n\ | |
1142 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1143 @seealso{stat, lstat}\n\ | |
1144 @end deftypefn") | |
1145 { | |
1146 octave_value retval = false; | |
1147 | |
1148 if (args.length () == 1) | |
1149 { | |
1150 double mode = args(0).double_value (); | |
1151 | |
1152 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1153 retval = file_stat::is_lnk (static_cast<mode_t> (mode)); |
5476 | 1154 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1155 error ("S_ISLNK: invalid MODE value"); |
5476 | 1156 } |
1157 else | |
5823 | 1158 print_usage (); |
5476 | 1159 |
1160 return retval; | |
1161 } | |
1162 | |
1163 DEFUNX ("S_ISSOCK", FS_ISSOCK, args, , | |
1164 "-*- texinfo -*-\n\ | |
1165 @deftypefn {Built-in Function} {} S_ISSOCK (@var{mode})\n\ | |
12212
f1ab2a12b4f4
Add S_ISSOCK function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
1166 Return true if @var{mode} corresponds to a socket. The value\n\ |
f1ab2a12b4f4
Add S_ISSOCK function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
1167 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1168 @seealso{stat, lstat}\n\ |
1169 @end deftypefn") | |
1170 { | |
1171 octave_value retval = false; | |
1172 | |
1173 if (args.length () == 1) | |
1174 { | |
1175 double mode = args(0).double_value (); | |
1176 | |
1177 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1178 retval = file_stat::is_sock (static_cast<mode_t> (mode)); |
5476 | 1179 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1180 error ("S_ISSOCK: invalid MODE value"); |
5476 | 1181 } |
1182 else | |
5823 | 1183 print_usage (); |
5476 | 1184 |
1185 return retval; | |
1186 } | |
1187 | |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1188 DEFUN (gethostname, args, , |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1189 "-*- texinfo -*-\n\ |
12514
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1190 @deftypefn {Built-in Function} {} gethostname ()\n\ |
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1191 Return the hostname of the system where Octave is running.\n\ |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1192 @end deftypefn") |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1193 { |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1194 octave_value retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1195 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1196 if (args.length () == 0) |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1197 retval = octave_env::get_host_name (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1198 else |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1199 print_usage (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1200 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1201 return retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1202 } |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1203 |
5547 | 1204 DEFUN (uname, args, , |
1205 "-*- texinfo -*-\n\ | |
1206 @deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\ | |
10840 | 1207 Return system information in the structure. For example:\n\ |
5547 | 1208 \n\ |
1209 @example\n\ | |
1210 @group\n\ | |
1211 uname ()\n\ | |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1212 @result{} @{\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1213 sysname = x86_64\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1214 nodename = segfault\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1215 release = 2.6.15-1-amd64-k8-smp\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1216 version = Linux\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1217 machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1218 @}\n\ |
5547 | 1219 @end group\n\ |
1220 @end example\n\ | |
1221 \n\ | |
1222 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ | |
1223 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
1224 system-dependent error message.\n\ | |
1225 @end deftypefn") | |
1226 { | |
1227 octave_value_list retval; | |
1228 | |
1229 if (args.length () == 0) | |
1230 { | |
1231 octave_uname sysinfo; | |
1232 | |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1233 octave_scalar_map m; |
5547 | 1234 |
1235 m.assign ("sysname", sysinfo.sysname ()); | |
1236 m.assign ("nodename", sysinfo.nodename ()); | |
1237 m.assign ("release", sysinfo.release ()); | |
1238 m.assign ("version", sysinfo.version ()); | |
1239 m.assign ("machine", sysinfo.machine ()); | |
1240 | |
1241 retval(2) = sysinfo.message (); | |
1242 retval(1) = sysinfo.error (); | |
1243 retval(0) = m; | |
1244 } | |
1245 else | |
5823 | 1246 print_usage (); |
5547 | 1247 |
1248 return retval; | |
1249 } | |
1250 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1251 DEFUNX ("unlink", Funlink, args, , |
3301 | 1252 "-*- texinfo -*-\n\ |
1253 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\ | |
1254 Delete the file named @var{file}.\n\ | |
2075 | 1255 \n\ |
3301 | 1256 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
1257 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
1258 system-dependent error message.\n\ | |
1259 @end deftypefn") | |
2075 | 1260 { |
2669 | 1261 octave_value_list retval; |
1262 | |
3523 | 1263 retval(1) = std::string (); |
4294 | 1264 retval(0) = -1; |
2075 | 1265 |
1266 int nargin = args.length (); | |
1267 | |
1268 if (nargin == 1) | |
1269 { | |
1270 if (args(0).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1271 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1272 std::string name = args(0).string_value (); |
2075 | 1273 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1274 std::string msg; |
2669 | 1275 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1276 int status = octave_unlink (name, msg); |
2669 | 1277 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1278 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1279 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1280 } |
2075 | 1281 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1282 error ("unlink: FILE must be a string"); |
2075 | 1283 } |
1284 else | |
5823 | 1285 print_usage (); |
2075 | 1286 |
1287 return retval; | |
1288 } | |
1289 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
1290 DEFUNX ("waitpid", Fwaitpid, args, , |
3301 | 1291 "-*- texinfo -*-\n\ |
5453 | 1292 @deftypefn {Built-in Function} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})\n\ |
3301 | 1293 Wait for process @var{pid} to terminate. The @var{pid} argument can be:\n\ |
2075 | 1294 \n\ |
3301 | 1295 @table @asis\n\ |
1296 @item @minus{}1\n\ | |
1297 Wait for any child process.\n\ | |
2075 | 1298 \n\ |
3301 | 1299 @item 0\n\ |
1300 Wait for any child process whose process group ID is equal to that of\n\ | |
1301 the Octave interpreter process.\n\ | |
2075 | 1302 \n\ |
3301 | 1303 @item > 0\n\ |
1304 Wait for termination of the child process with ID @var{pid}.\n\ | |
1305 @end table\n\ | |
1306 \n\ | |
5453 | 1307 The @var{options} argument can be a bitwise OR of zero or more of\n\ |
1308 the following constants:\n\ | |
2075 | 1309 \n\ |
5453 | 1310 @table @code\n\ |
3301 | 1311 @item 0\n\ |
1312 Wait until signal is received or a child process exits (this is the\n\ | |
1313 default if the @var{options} argument is missing).\n\ | |
1314 \n\ | |
5453 | 1315 @item WNOHANG\n\ |
3301 | 1316 Do not hang if status is not immediately available.\n\ |
2075 | 1317 \n\ |
5453 | 1318 @item WUNTRACED\n\ |
3301 | 1319 Report the status of any child processes that are stopped, and whose\n\ |
1320 status has not yet been reported since they stopped.\n\ | |
1321 \n\ | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7924
diff
changeset
|
1322 @item WCONTINUE\n\ |
5453 | 1323 Return if a stopped child has been resumed by delivery of @code{SIGCONT}.\n\ |
1324 This value may not be meaningful on all systems.\n\ | |
3301 | 1325 @end table\n\ |
1326 \n\ | |
1327 If the returned value of @var{pid} is greater than 0, it is the process\n\ | |
1328 ID of the child process that exited. If an error occurs, @var{pid} will\n\ | |
1329 be less than zero and @var{msg} will contain a system-dependent error\n\ | |
7001 | 1330 message. The value of @var{status} contains additional system-dependent\n\ |
5453 | 1331 information about the subprocess that exited.\n\ |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7924
diff
changeset
|
1332 @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}\n\ |
3301 | 1333 @end deftypefn") |
2075 | 1334 { |
2669 | 1335 octave_value_list retval; |
1336 | |
5453 | 1337 retval(2) = std::string (); |
1338 retval(1) = 0; | |
4294 | 1339 retval(0) = -1; |
2075 | 1340 |
1341 int nargin = args.length (); | |
1342 | |
1343 if (nargin == 1 || nargin == 2) | |
1344 { | |
3202 | 1345 pid_t pid = args(0).int_value (true); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1346 |
2075 | 1347 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1348 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1349 int options = 0; |
2075 | 1350 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1351 if (args.length () == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1352 options = args(1).int_value (true); |
2937 | 1353 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1354 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1355 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1356 std::string msg; |
2669 | 1357 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1358 int status = 0; |
5453 | 1359 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1360 pid_t result = octave_syscalls::waitpid (pid, &status, options, msg); |
3202 | 1361 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1362 retval(2) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1363 retval(1) = status; |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1364 retval(0) = result; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1365 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1366 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1367 error ("waitpid: OPTIONS must be an integer"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1368 } |
3202 | 1369 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1370 error ("waitpid: PID must be an integer value"); |
2075 | 1371 } |
1372 else | |
5823 | 1373 print_usage (); |
2075 | 1374 |
1375 return retval; | |
1376 } | |
1377 | |
5453 | 1378 DEFUNX ("WIFEXITED", FWIFEXITED, args, , |
1379 "-*- texinfo -*-\n\ | |
1380 @deftypefn {Built-in Function} {} WIFEXITED (@var{status})\n\ | |
1381 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1382 child terminated normally.\n\ | |
1383 @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
5646 | 1384 @end deftypefn") |
5453 | 1385 { |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1386 octave_value retval = false; |
5453 | 1387 |
1388 if (args.length () == 1) | |
1389 { | |
1390 int status = args(0).int_value (); | |
1391 | |
1392 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1393 retval = octave_wait::ifexited (status); |
5453 | 1394 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1395 error ("WIFEXITED: STATUS must be an integer"); |
5453 | 1396 } |
1397 | |
1398 return retval; | |
1399 } | |
1400 | |
1401 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, , | |
1402 "-*- texinfo -*-\n\ | |
1403 @deftypefn {Built-in Function} {} WEXITSTATUS (@var{status})\n\ | |
1404 Given @var{status} from a call to @code{waitpid}, return the exit\n\ | |
1405 status of the child. This function should only be employed if\n\ | |
1406 @code{WIFEXITED} returned true.\n\ | |
1407 @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1408 @end deftypefn") | |
1409 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1410 octave_value retval = 0; |
5453 | 1411 |
1412 if (args.length () == 1) | |
1413 { | |
1414 int status = args(0).int_value (); | |
1415 | |
1416 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1417 retval = octave_wait::exitstatus (status); |
5453 | 1418 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1419 error ("WEXITSTATUS: STATUS must be an integer"); |
5453 | 1420 } |
1421 | |
1422 return retval; | |
1423 } | |
1424 | |
1425 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, , | |
1426 "-*- texinfo -*-\n\ | |
1427 @deftypefn {Built-in Function} {} WIFSIGNALED (@var{status})\n\ | |
1428 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1429 child process was terminated by a signal.\n\ | |
1430 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1431 @end deftypefn") | |
1432 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1433 octave_value retval = false; |
5453 | 1434 |
1435 if (args.length () == 1) | |
1436 { | |
1437 int status = args(0).int_value (); | |
1438 | |
1439 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1440 retval = octave_wait::ifsignaled (status); |
5453 | 1441 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1442 error ("WIFSIGNALED: STATUS must be an integer"); |
5453 | 1443 } |
1444 | |
1445 return retval; | |
1446 } | |
1447 | |
1448 DEFUNX ("WTERMSIG", FWTERMSIG, args, , | |
1449 "-*- texinfo -*-\n\ | |
1450 @deftypefn {Built-in Function} {} WTERMSIG (@var{status})\n\ | |
1451 Given @var{status} from a call to @code{waitpid}, return the number of\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1452 the signal that caused the child process to terminate. This function\n\ |
5453 | 1453 should only be employed if @code{WIFSIGNALED} returned true.\n\ |
1454 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1455 @end deftypefn") | |
1456 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1457 octave_value retval = 0; |
5453 | 1458 |
1459 if (args.length () == 1) | |
1460 { | |
1461 int status = args(0).int_value (); | |
1462 | |
1463 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1464 retval = octave_wait::termsig (status); |
5453 | 1465 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1466 error ("WTERMSIG: STATUS must be an integer"); |
5453 | 1467 } |
1468 | |
1469 return retval; | |
1470 } | |
1471 | |
1472 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, , | |
1473 "-*- texinfo -*-\n\ | |
1474 @deftypefn {Built-in Function} {} WCOREDUMP (@var{status})\n\ | |
1475 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1476 child produced a core dump. This function should only be employed if\n\ | |
1477 @code{WIFSIGNALED} returned true. The macro used to implement this\n\ | |
1478 function is not specified in POSIX.1-2001 and is not available on some\n\ | |
1479 Unix implementations (e.g., AIX, SunOS).\n\ | |
1480 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1481 @end deftypefn") | |
1482 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1483 octave_value retval = false; |
5453 | 1484 |
1485 if (args.length () == 1) | |
1486 { | |
1487 int status = args(0).int_value (); | |
1488 | |
1489 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1490 retval = octave_wait::coredump (status); |
5453 | 1491 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1492 error ("WCOREDUMP: STATUS must be an integer"); |
5453 | 1493 } |
1494 | |
1495 return retval; | |
1496 } | |
1497 | |
1498 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, , | |
1499 "-*- texinfo -*-\n\ | |
1500 @deftypefn {Built-in Function} {} WIFSTOPPED (@var{status})\n\ | |
1501 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1502 child process was stopped by delivery of a signal; this is only\n\ | |
1503 possible if the call was done using @code{WUNTRACED} or when the child\n\ | |
1504 is being traced (see ptrace(2)).\n\ | |
1505 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WSTOPSIG, WIFCONTINUED}\n\ | |
1506 @end deftypefn") | |
1507 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1508 octave_value retval = false; |
5453 | 1509 |
1510 if (args.length () == 1) | |
1511 { | |
1512 int status = args(0).int_value (); | |
1513 | |
1514 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1515 retval = octave_wait::ifstopped (status); |
5453 | 1516 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1517 error ("WIFSTOPPED: STATUS must be an integer"); |
5453 | 1518 } |
1519 | |
1520 return retval; | |
1521 } | |
1522 | |
1523 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, , | |
1524 "-*- texinfo -*-\n\ | |
1525 @deftypefn {Built-in Function} {} WSTOPSIG (@var{status})\n\ | |
1526 Given @var{status} from a call to @code{waitpid}, return the number of\n\ | |
1527 the signal which caused the child to stop. This function should only\n\ | |
1528 be employed if @code{WIFSTOPPED} returned true.\n\ | |
1529 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WIFCONTINUED}\n\ | |
1530 @end deftypefn") | |
1531 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1532 octave_value retval = 0; |
5453 | 1533 |
1534 if (args.length () == 1) | |
1535 { | |
1536 int status = args(0).int_value (); | |
1537 | |
1538 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1539 retval = octave_wait::stopsig (status); |
5453 | 1540 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1541 error ("WSTOPSIG: STATUS must be an integer"); |
5453 | 1542 } |
1543 | |
1544 return retval; | |
1545 } | |
1546 | |
1547 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, , | |
1548 "-*- texinfo -*-\n\ | |
1549 @deftypefn {Built-in Function} {} WIFCONTINUED (@var{status})\n\ | |
1550 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1551 child process was resumed by delivery of @code{SIGCONT}.\n\ | |
1552 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG}\n\ | |
1553 @end deftypefn") | |
1554 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1555 octave_value retval = false; |
5453 | 1556 |
1557 if (args.length () == 1) | |
1558 { | |
1559 int status = args(0).int_value (); | |
1560 | |
1561 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1562 retval = octave_wait::ifcontinued (status); |
5453 | 1563 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1564 error ("WIFCONTINUED: STATUS must be an integer"); |
5453 | 1565 } |
1566 | |
1567 return retval; | |
1568 } | |
1569 | |
10249
14eba566f9f0
use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
1570 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, , |
5138 | 1571 "-*- texinfo -*-\n\ |
14819
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1572 @deftypefn {Built-in Function} {[@var{cname}, @var{status}, @var{msg}] =} canonicalize_file_name (@var{fname})\n\ |
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1573 Return the canonical name of file @var{fname}. If the file does not exist\n\ |
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1574 the empty string (\"\") is returned.\n\ |
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1575 @seealso{make_absolute_filename, is_absolute_filename, is_rooted_relative_filename}\n\ |
5138 | 1576 @end deftypefn") |
1577 { | |
1578 octave_value_list retval; | |
1579 | |
1580 if (args.length () == 1) | |
1581 { | |
1582 std::string name = args(0).string_value (); | |
1583 | |
1584 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1585 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1586 std::string msg; |
5138 | 1587 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1588 std::string result = octave_canonicalize_file_name (name, msg); |
5138 | 1589 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1590 retval(2) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1591 retval(1) = msg.empty () ? 0 : -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1592 retval(0) = result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1593 } |
5138 | 1594 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1595 error ("canonicalize_file_name: NAME must be a character string"); |
5138 | 1596 } |
1597 else | |
5823 | 1598 print_usage (); |
5138 | 1599 |
1600 return retval; | |
1601 } | |
1602 | |
5749 | 1603 static octave_value |
7924 | 1604 const_value (const octave_value_list& args, int val) |
5749 | 1605 { |
1606 octave_value retval; | |
1607 | |
1608 int nargin = args.length (); | |
1609 | |
1610 if (nargin == 0) | |
1611 retval = val; | |
1612 else | |
5823 | 1613 print_usage (); |
5749 | 1614 |
1615 return retval; | |
1616 } | |
1617 | |
2075 | 1618 #if !defined (O_NONBLOCK) && defined (O_NDELAY) |
1619 #define O_NONBLOCK O_NDELAY | |
1620 #endif | |
1621 | |
5749 | 1622 DEFUNX ("F_DUPFD", FF_DUPFD, args, , |
1623 "-*- texinfo -*-\n\ | |
1624 @deftypefn {Built-in Function} {} F_DUPFD ()\n\ | |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1625 Return the numerical value to pass to @code{fcntl} to return a\n\ |
5749 | 1626 duplicate file descriptor.\n\ |
1627 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\ | |
1628 @end deftypefn") | |
2075 | 1629 { |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1630 #if defined (F_DUPFD) |
7924 | 1631 return const_value (args, F_DUPFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1632 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1633 error ("F_DUPFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1634 return octave_value (); |
2075 | 1635 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1636 } |
2075 | 1637 |
5749 | 1638 DEFUNX ("F_GETFD", FF_GETFD, args, , |
1639 "-*- texinfo -*-\n\ | |
1640 @deftypefn {Built-in Function} {} F_GETFD ()\n\ | |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1641 Return the numerical value to pass to @code{fcntl} to return the\n\ |
5749 | 1642 file descriptor flags.\n\ |
5333 | 1643 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\ |
5749 | 1644 @end deftypefn") |
1645 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1646 #if defined (F_GETFD) |
7924 | 1647 return const_value (args, F_GETFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1648 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1649 error ("F_GETFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1650 return octave_value (); |
2075 | 1651 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1652 } |
2075 | 1653 |
5749 | 1654 DEFUNX ("F_GETFL", FF_GETFL, args, , |
1655 "-*- texinfo -*-\n\ | |
1656 @deftypefn {Built-in Function} {} F_GETFL ()\n\ | |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1657 Return the numerical value to pass to @code{fcntl} to return the\n\ |
5749 | 1658 file status flags.\n\ |
5333 | 1659 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\ |
5749 | 1660 @end deftypefn") |
1661 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1662 #if defined (F_GETFL) |
7924 | 1663 return const_value (args, F_GETFL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1664 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1665 error ("F_GETFL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1666 return octave_value (); |
2075 | 1667 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1668 } |
2075 | 1669 |
5749 | 1670 DEFUNX ("F_SETFD", FF_SETFD, args, , |
1671 "-*- texinfo -*-\n\ | |
1672 @deftypefn {Built-in Function} {} F_SETFD ()\n\ | |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1673 Return the numerical value to pass to @code{fcntl} to set the file\n\ |
5749 | 1674 descriptor flags.\n\ |
5333 | 1675 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\ |
5749 | 1676 @end deftypefn") |
1677 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1678 #if defined (F_SETFD) |
7924 | 1679 return const_value (args, F_SETFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1680 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1681 error ("F_SETFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1682 return octave_value (); |
2075 | 1683 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1684 } |
2075 | 1685 |
5749 | 1686 DEFUNX ("F_SETFL", FF_SETFL, args, , |
1687 "-*- texinfo -*-\n\ | |
1688 @deftypefn {Built-in Function} {} F_SETFL ()\n\ | |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1689 Return the numerical value to pass to @code{fcntl} to set the file\n\ |
5749 | 1690 status flags.\n\ |
5333 | 1691 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\ |
5749 | 1692 @end deftypefn") |
1693 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1694 #if defined (F_SETFL) |
7924 | 1695 return const_value (args, F_SETFL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1696 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1697 error ("F_SETFL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1698 return octave_value (); |
2075 | 1699 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1700 } |
2075 | 1701 |
5749 | 1702 DEFUNX ("O_APPEND", FO_APPEND, args, , |
1703 "-*- texinfo -*-\n\ | |
1704 @deftypefn {Built-in Function} {} O_APPEND ()\n\ | |
1705 Return the numerical value of the file status flag that may be\n\ | |
1706 returned by @code{fcntl} to indicate each write operation appends,\n\ | |
11152
39ae406df598
Improve docstrings for functions found in undocumented list.
Rik <octave@nomad.inbox5.com>
parents:
11006
diff
changeset
|
1707 or that may be passed to @code{fcntl} to set the write mode to append.\n\ |
5333 | 1708 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1709 @end deftypefn") |
1710 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1711 #if defined (O_APPEND) |
7924 | 1712 return const_value (args, O_APPEND); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1713 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1714 error ("O_APPEND: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1715 return octave_value (); |
2075 | 1716 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1717 } |
2075 | 1718 |
5749 | 1719 DEFUNX ("O_ASYNC", FO_ASYNC, args, , |
1720 "-*- texinfo -*-\n\ | |
1721 @deftypefn {Built-in Function} {} O_ASYNC ()\n\ | |
1722 Return the numerical value of the file status flag that may be\n\ | |
1723 returned by @code{fcntl} to indicate asynchronous I/O.\n\ | |
5333 | 1724 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1725 @end deftypefn") |
1726 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1727 #if defined (O_ASYNC) |
7924 | 1728 return const_value (args, O_ASYNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1729 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1730 error ("O_ASYNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1731 return octave_value (); |
2669 | 1732 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1733 } |
2669 | 1734 |
5749 | 1735 DEFUNX ("O_CREAT", FO_CREAT, args, , |
1736 "-*- texinfo -*-\n\ | |
1737 @deftypefn {Built-in Function} {} O_CREAT ()\n\ | |
1738 Return the numerical value of the file status flag that may be\n\ | |
1739 returned by @code{fcntl} to indicate that a file should be\n\ | |
1740 created if it does not exist.\n\ | |
5333 | 1741 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1742 @end deftypefn") |
1743 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1744 #if defined (O_CREAT) |
7924 | 1745 return const_value (args, O_CREAT); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1746 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1747 error ("O_CREAT: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1748 return octave_value (); |
2075 | 1749 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1750 } |
2075 | 1751 |
5749 | 1752 DEFUNX ("O_EXCL", FO_EXCL, args, , |
1753 "-*- texinfo -*-\n\ | |
1754 @deftypefn {Built-in Function} {} O_EXCL ()\n\ | |
1755 Return the numerical value of the file status flag that may be\n\ | |
1756 returned by @code{fcntl} to indicate that file locking is used.\n\ | |
5333 | 1757 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1758 @end deftypefn") |
1759 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1760 #if defined (O_EXCL) |
7924 | 1761 return const_value (args, O_EXCL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1762 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1763 error ("O_EXCL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1764 return octave_value (); |
2075 | 1765 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1766 } |
2075 | 1767 |
5749 | 1768 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, , |
1769 "-*- texinfo -*-\n\ | |
1770 @deftypefn {Built-in Function} {} O_NONBLOCK ()\n\ | |
1771 Return the numerical value of the file status flag that may be\n\ | |
1772 returned by @code{fcntl} to indicate that non-blocking I/O is in use,\n\ | |
1773 or that may be passsed to @code{fcntl} to set non-blocking I/O.\n\ | |
5333 | 1774 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1775 @end deftypefn") |
1776 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1777 #if defined (O_NONBLOCK) |
7924 | 1778 return const_value (args, O_NONBLOCK); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1779 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1780 error ("O_NONBLOCK: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1781 return octave_value (); |
2075 | 1782 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1783 } |
2075 | 1784 |
5749 | 1785 DEFUNX ("O_RDONLY", FO_RDONLY, args, , |
1786 "-*- texinfo -*-\n\ | |
1787 @deftypefn {Built-in Function} {} O_RDONLY ()\n\ | |
1788 Return the numerical value of the file status flag that may be\n\ | |
1789 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1790 reading only.\n\ | |
5333 | 1791 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1792 @end deftypefn") |
1793 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1794 #if defined (O_RDONLY) |
7924 | 1795 return const_value (args, O_RDONLY); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1796 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1797 error ("O_RDONLY: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1798 return octave_value (); |
2075 | 1799 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1800 } |
2075 | 1801 |
5749 | 1802 DEFUNX ("O_RDWR", FO_RDWR, args, , |
1803 "-*- texinfo -*-\n\ | |
1804 @deftypefn {Built-in Function} {} O_RDWR ()\n\ | |
1805 Return the numerical value of the file status flag that may be\n\ | |
1806 returned by @code{fcntl} to indicate that a file is open for both\n\ | |
1807 reading and writing.\n\ | |
5333 | 1808 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1809 @end deftypefn") |
1810 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1811 #if defined (O_RDWR) |
7924 | 1812 return const_value (args, O_RDWR); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1813 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1814 error ("O_RDWR: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1815 return octave_value (); |
2075 | 1816 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1817 } |
2075 | 1818 |
5749 | 1819 DEFUNX ("O_SYNC", FO_SYNC, args, , |
1820 "-*- texinfo -*-\n\ | |
1821 @deftypefn {Built-in Function} {} O_SYNC ()\n\ | |
1822 Return the numerical value of the file status flag that may be\n\ | |
1823 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1824 synchronous I/O.\n\ | |
5333 | 1825 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\ |
5749 | 1826 @end deftypefn") |
1827 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1828 #if defined (O_SYNC) |
7924 | 1829 return const_value (args, O_SYNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1830 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1831 error ("O_SYNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1832 return octave_value (); |
2669 | 1833 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1834 } |
2669 | 1835 |
5749 | 1836 DEFUNX ("O_TRUNC", FO_TRUNC, args, , |
1837 "-*- texinfo -*-\n\ | |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11546
diff
changeset
|
1838 @deftypefn {Built-in Function} O_TRUNC ()\n\ |
5749 | 1839 Return the numerical value of the file status flag that may be\n\ |
1840 returned by @code{fcntl} to indicate that if file exists, it should\n\ | |
1841 be truncated when writing.\n\ | |
5333 | 1842 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\ |
5749 | 1843 @end deftypefn") |
1844 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1845 #if defined (O_TRUNC) |
7924 | 1846 return const_value (args, O_TRUNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1847 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1848 error ("O_TRUNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1849 return octave_value (); |
2075 | 1850 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1851 } |
2075 | 1852 |
5749 | 1853 DEFUNX ("O_WRONLY", FO_WRONLY, args, , |
1854 "-*- texinfo -*-\n\ | |
1855 @deftypefn {Built-in Function} {} O_WRONLY ()\n\ | |
1856 Return the numerical value of the file status flag that may be\n\ | |
1857 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1858 writing only.\n\ | |
5333 | 1859 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\ |
5749 | 1860 @end deftypefn") |
1861 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1862 #if defined (O_WRONLY) |
7924 | 1863 return const_value (args, O_WRONLY); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1864 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1865 error ("O_WRONLY: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1866 return octave_value (); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1867 #endif |
5749 | 1868 } |
3446 | 1869 |
5453 | 1870 #if !defined (WNOHANG) |
1871 #define WNOHANG 0 | |
1872 #endif | |
1873 | |
5749 | 1874 DEFUNX ("WNOHANG", FWNOHANG, args, , |
1875 "-*- texinfo -*-\n\ | |
1876 @deftypefn {Built-in Function} {} WNOHANG ()\n\ | |
1877 Return the numerical value of the option argument that may be\n\ | |
1878 passed to @code{waitpid} to indicate that it should return its\n\ | |
1879 status immediately instead of waiting for a process to exit.\n\ | |
5453 | 1880 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\ |
5749 | 1881 @end deftypefn") |
1882 { | |
7924 | 1883 return const_value (args, WNOHANG); |
5749 | 1884 } |
5453 | 1885 |
1886 #if !defined (WUNTRACED) | |
1887 #define WUNTRACED 0 | |
1888 #endif | |
1889 | |
5749 | 1890 DEFUNX ("WUNTRACED", FWUNTRACED, args, , |
1891 "-*- texinfo -*-\n\ | |
1892 @deftypefn {Built-in Function} {} WUNTRACED ()\n\ | |
1893 Return the numerical value of the option argument that may be\n\ | |
1894 passed to @code{waitpid} to indicate that it should also return\n\ | |
1895 if the child process has stopped but is not traced via the\n\ | |
1896 @code{ptrace} system call\n\ | |
5453 | 1897 @seealso{waitpid, WNOHANG, WCONTINUE}\n\ |
5749 | 1898 @end deftypefn") |
1899 { | |
7924 | 1900 return const_value (args, WUNTRACED); |
5749 | 1901 } |
5453 | 1902 |
1903 #if !defined (WCONTINUE) | |
1904 #define WCONTINUE 0 | |
1905 #endif | |
1906 | |
5749 | 1907 DEFUNX ("WCONTINUE", FWCONTINUE, args, , |
1908 "-*- texinfo -*-\n\ | |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9564
diff
changeset
|
1909 @deftypefn {Built-in Function} {} WCONTINUE ()\n\ |
5749 | 1910 Return the numerical value of the option argument that may be\n\ |
1911 passed to @code{waitpid} to indicate that it should also return\n\ | |
1912 if a stopped child has been resumed by delivery of a @code{SIGCONT}\n\ | |
1913 signal.\n\ | |
5453 | 1914 @seealso{waitpid, WNOHANG, WUNTRACED}\n\ |
5749 | 1915 @end deftypefn") |
1916 { | |
7924 | 1917 return const_value (args, WCONTINUE); |
2075 | 1918 } |