Mercurial > octave
annotate libinterp/corefcn/syscalls.cc @ 20791:f7084eae3318
maint: Use Octave coding conventions for #if statements.
* mk-opts.pl, dialog.h, find-files-dialog.h, find-files-model.h,
file-editor-tab.h, octave-qscintilla.h, octave-txt-lexer.h, main-window.h,
octave-cmd.h, octave-dock-widget.h, octave-gui.h, thread-manager.h,
workspace-model.h, workspace-view.h, builtins.h, Cell.h, bitfcns.cc,
c-file-ptr-stream.h, cdisplay.h, comment-list.h, cutils.h, data.h, debug.h,
defaults.in.h, defun-dld.h, defun-int.h, defun.h, dirfns.h, display.h,
dynamic-ld.h, error.h, event-queue.h, file-io.h, filter.cc, getrusage.cc,
gl-render.h, gl2ps-renderer.h, graphics.in.h, gripes.h, help.h, hook-fcn.h,
input.h, jit-ir.h, jit-typeinfo.h, jit-util.h, load-path.h, load-save.h,
ls-ascii-helper.h, ls-hdf5.h, ls-mat-ascii.h, ls-mat4.h, ls-mat5.h,
ls-oct-binary.h, ls-oct-text.h, ls-utils.h, oct-errno.h, oct-fstrm.h,
oct-handle.h, oct-hdf5-types.h, oct-hdf5.h, oct-hist.h, oct-iostrm.h,
oct-lvalue.h, oct-map.h, oct-obj.h, oct-prcstrm.h, oct-procbuf.h,
oct-stdstrm.h, oct-stream.h, oct-strstrm.h, oct.h, octave-link.h, pager.h,
pr-output.h, procstream.h, profiler.h, pt-jit.h, sighandlers.cc, sighandlers.h,
siglist.h, sparse-xdiv.h, sparse-xpow.h, symtab.h, syscalls.cc, sysdep.h,
toplev.cc, toplev.h, utils.h, variables.h, workspace-element.h, xdiv.h,
xnorm.h, xpow.h, dmperm.cc, oct-qhull.h, mkbuiltins, oct-conf.in.h,
ov-base-diag.h, ov-base-int.h, ov-base-mat.h, ov-base-scalar.h,
ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h, ov-bool.h,
ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h, ov-classdef.h, ov-colon.h,
ov-complex.h, ov-cs-list.h, ov-cx-diag.h, ov-cx-mat.h, ov-cx-sparse.h,
ov-dld-fcn.h, ov-fcn-handle.h, ov-fcn-inline.h, ov-fcn.h, ov-float.h,
ov-flt-complex.h, ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h,
ov-flt-re-mat.h, ov-int-traits.h, ov-int16.h, ov-int32.h, ov-int64.h,
ov-int8.h, ov-java.h, ov-lazy-idx.h, ov-mex-fcn.h, ov-null-mat.h, ov-perm.h,
ov-range.h, ov-re-diag.h, ov-re-mat.h, ov-re-sparse.h, ov-scalar.h,
ov-str-mat.h, ov-struct.h, ov-type-conv.h, ov-typeinfo.h, ov-uint16.h,
ov-uint32.h, ov-uint64.h, ov-uint8.h, ov-usr-fcn.h, ov.h, octave.h, ops.h,
options-usage.h, lex.h, parse.h, pt-all.h, pt-arg-list.h, pt-array-list.h,
pt-assign.h, pt-binop.h, pt-bp.h, pt-cbinop.h, pt-cell.h, pt-check.h,
pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h, pt-decl.h, pt-eval.h,
pt-except.h, pt-exp.h, pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-idx.h,
pt-jump.h, pt-loop.h, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-select.h,
pt-stmt.h, pt-unop.h, pt-walk.h, pt.h, token.h, version.in.h, Array-util.h,
Array.h, CColVector.h, CDiagMatrix.h, CMatrix.h, CNDArray.h, CRowVector.h,
CSparse.h, DiagArray2.h, MArray-decl.h, MArray-defs.h, MArray.h, MDiagArray2.h,
MSparse.h, Matrix.h, MatrixType.h, PermMatrix.h, Range.h, Sparse.h,
boolMatrix.h, boolNDArray.h, boolSparse.h, chMatrix.h, chNDArray.h,
dColVector.h, dDiagMatrix.h, dMatrix.h, dNDArray.h, dRowVector.h, dSparse.h,
dim-vector.h, fCColVector.h, fCDiagMatrix.h, fCMatrix.h, fCNDArray.h,
fCRowVector.h, fColVector.h, fDiagMatrix.h, fMatrix.h, fNDArray.h,
fRowVector.h, idx-vector.h, int16NDArray.h, int32NDArray.h, int64NDArray.h,
int8NDArray.h, intNDArray.h, uint16NDArray.h, uint32NDArray.h, uint64NDArray.h,
uint8NDArray.h, f77-fcn.h, lo-error.h, quit.h, CmplxAEPBAL.h, CmplxCHOL.h,
CmplxGEPBAL.h, CmplxHESS.h, CmplxLU.h, CmplxQR.h, CmplxQRP.h, CmplxSCHUR.h,
CmplxSVD.h, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.h,
DASRT.h, DASSL.h, DET.h, EIG.h, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h,
Quad.h, SparseCmplxCHOL.h, SparseCmplxLU.h, SparseCmplxQR.cc, SparseCmplxQR.h,
SparseQR.h, SparsedbleCHOL.h, SparsedbleLU.h, base-aepbal.h, base-dae.h,
base-de.h, base-lu.h, base-min.h, base-qr.h, bsxfun-decl.h, bsxfun-defs.cc,
bsxfun.h, dbleAEPBAL.h, dbleCHOL.h, dbleGEPBAL.h, dbleHESS.h, dbleLU.h,
dbleQR.h, dbleQRP.h, dbleSCHUR.h, dbleSVD.h, eigs-base.cc, fCmplxAEPBAL.h,
fCmplxCHOL.h, fCmplxGEPBAL.h, fCmplxHESS.h, fCmplxLU.h, fCmplxQR.h,
fCmplxQRP.h, fCmplxSCHUR.h, fCmplxSVD.h, fEIG.h, floatAEPBAL.h, floatCHOL.h,
floatGEPBAL.h, floatHESS.h, floatLU.h, floatQR.h, floatQRP.h, floatSCHUR.h,
floatSVD.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h,
oct-convn.h, oct-fftw.h, oct-norm.h, oct-rand.h, oct-spparms.h, randmtzig.c,
sparse-base-chol.h, sparse-base-lu.h, sparse-dmsolve.cc, Sparse-diag-op-defs.h,
Sparse-op-decls.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, mk-ops.awk,
mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc, mx-op-decl.h, mx-op-defs.h,
sparse-mk-ops.awk, dir-ops.h, file-ops.h, file-stat.h, lo-sysdep.h,
mach-info.h, oct-env.h, oct-group.h, oct-openmp.h, oct-passwd.h,
oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.h, pathlen.h, sysdir.h,
syswait.h, action-container.h, base-list.h, byte-swap.h, caseless-str.h,
cmd-edit.h, cmd-hist.h, data-conv.h, functor.h, glob-match.h, kpse.cc,
lo-array-gripes.h, lo-cutils.h, lo-ieee.h, lo-macros.h, lo-math.h, lo-regexp.h,
lo-traits.h, lo-utils.h, oct-alloc.h, oct-base64.h, oct-binmap.h, oct-cmplx.h,
oct-glob.h, oct-inttypes.h, oct-locbuf.h, oct-mutex.h, oct-refcount.h,
oct-rl-edit.h, oct-rl-hist.h, oct-shlib.h, oct-sort.h, oct-sparse.h,
pathsearch.h, singleton-cleanup.h, sparse-sort.h, sparse-util.h, statdefs.h,
str-vec.h, sun-utils.h, unwind-prot.h, url-transfer.h:
Use Octave coding conventions for #if statements.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 03 Dec 2015 10:23:38 -0800 |
parents | 0ad449bc8848 |
children | fb128aafc322 |
rev | line source |
---|---|
2075 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
3 Copyright (C) 1996-2015 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 | |
17236
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" |
17236
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, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 "-*- texinfo -*-\n\ |
3301 | 114 @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})\n\ |
2669 | 115 Duplicate a file descriptor.\n\ |
116 \n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
117 If successful, @var{fid} is greater than zero and contains the new file ID@.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
118 Otherwise, @var{fid} is negative and @var{msg} contains a system-dependent\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
119 error message.\n\ |
19109
e90bfaadb489
doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents:
18112
diff
changeset
|
120 @seealso{fopen, fclose, fcntl}\n\ |
3301 | 121 @end deftypefn") |
2075 | 122 { |
2669 | 123 octave_value_list retval; |
124 | |
3523 | 125 retval(1) = std::string (); |
4294 | 126 retval(0) = -1; |
2075 | 127 |
128 int nargin = args.length (); | |
129 | |
130 if (nargin == 2) | |
131 { | |
3341 | 132 octave_stream old_stream |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
133 = octave_stream_list::lookup (args(0), "dup2"); |
2075 | 134 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
135 octave_stream new_stream |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
136 = octave_stream_list::lookup (args(1), "dup2"); |
2075 | 137 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
138 int i_old = old_stream.file_number (); |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
139 int i_new = new_stream.file_number (); |
2937 | 140 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
141 if (i_old >= 0 && i_new >= 0) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
142 { |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
143 std::string msg; |
3341 | 144 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
145 int status = octave_syscalls::dup2 (i_old, i_new, msg); |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
146 |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
147 retval(1) = msg; |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
148 retval(0) = status; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
149 } |
2075 | 150 } |
151 else | |
5823 | 152 print_usage (); |
2075 | 153 |
154 return retval; | |
155 } | |
156 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
157 DEFUNX ("exec", Fexec, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
158 "-*- texinfo -*-\n\ |
3301 | 159 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} exec (@var{file}, @var{args})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
160 Replace current process with a new process.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
161 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
162 Calling @code{exec} without first calling @code{fork} will terminate your\n\ |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
163 current Octave process and replace it with the program named by @var{file}.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
164 For example,\n\ |
2669 | 165 \n\ |
3301 | 166 @example\n\ |
167 exec (\"ls\" \"-l\")\n\ | |
168 @end example\n\ | |
2669 | 169 \n\ |
3301 | 170 @noindent\n\ |
171 will run @code{ls} and return you to your shell prompt.\n\ | |
172 \n\ | |
173 If successful, @code{exec} does not return. If @code{exec} does return,\n\ | |
174 @var{err} will be nonzero, and @var{msg} will contain a system-dependent\n\ | |
175 error message.\n\ | |
176 @end deftypefn") | |
2075 | 177 { |
2669 | 178 octave_value_list retval; |
179 | |
3523 | 180 retval(1) = std::string (); |
4294 | 181 retval(0) = -1; |
2075 | 182 |
183 int nargin = args.length (); | |
184 | |
185 if (nargin == 1 || nargin == 2) | |
186 { | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
187 std::string exec_file = args(0).xstring_value ("exec: FILE must be a string"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
188 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
189 string_vector exec_args; |
2075 | 190 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
191 if (nargin == 2) |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
192 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
193 string_vector tmp = args(1).xall_strings ("exec: all arguments must be strings"); |
2075 | 194 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
195 int len = tmp.numel (); |
2075 | 196 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
197 exec_args.resize (len + 1); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
198 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
199 exec_args[0] = exec_file; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
200 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
201 for (int i = 0; i < len; i++) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
202 exec_args[i+1] = tmp[i]; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
203 } |
2075 | 204 else |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
205 { |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
206 exec_args.resize (1); |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
207 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
208 exec_args[0] = exec_file; |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
209 } |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
210 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
211 octave_history_write_timestamp (); |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
212 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
213 if (! command_history::ignoring_entries ()) |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
214 command_history::clean_up_and_save (); |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
215 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
216 std::string msg; |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
217 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
218 int status = octave_syscalls::execvp (exec_file, exec_args, msg); |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
219 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
220 retval(1) = msg; |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
221 retval(0) = status; |
2075 | 222 } |
223 else | |
5823 | 224 print_usage (); |
2075 | 225 |
226 return retval; | |
227 } | |
228 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
229 DEFUNX ("popen2", Fpopen2, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
230 "-*- texinfo -*-\n\ |
6678 | 231 @deftypefn {Built-in Function} {[@var{in}, @var{out}, @var{pid}] =} popen2 (@var{command}, @var{args})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
232 Start a subprocess with two-way communication.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
233 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
234 The name of the process is given by @var{command}, and @var{args} is an\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
235 array of strings containing options for the command.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
236 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
237 The file identifiers for the input and output streams of the subprocess are\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
238 returned in @var{in} and @var{out}. If execution of the command is\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
239 successful, @var{pid} contains the process ID of the subprocess. Otherwise,\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
240 @var{pid} is @minus{}1.\n\ |
6321 | 241 \n\ |
10840 | 242 For example:\n\ |
6321 | 243 \n\ |
244 @example\n\ | |
6923 | 245 [in, out, pid] = popen2 (\"sort\", \"-r\");\n\ |
6321 | 246 fputs (in, \"these\\nare\\nsome\\nstrings\\n\");\n\ |
247 fclose (in);\n\ | |
248 EAGAIN = errno (\"EAGAIN\");\n\ | |
249 done = false;\n\ | |
250 do\n\ | |
251 s = fgets (out);\n\ | |
252 if (ischar (s))\n\ | |
253 fputs (stdout, s);\n\ | |
254 elseif (errno () == EAGAIN)\n\ | |
255 sleep (0.1);\n\ | |
256 fclear (out);\n\ | |
257 else\n\ | |
258 done = true;\n\ | |
259 endif\n\ | |
260 until (done)\n\ | |
261 fclose (out);\n\ | |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
262 waitpid (pid);\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
263 \n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
264 @print{} these\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
265 @print{} strings\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
266 @print{} some\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
267 @print{} are\n\ |
6321 | 268 @end example\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
269 \n\ |
17968
43c199e83ed7
Reap child process in popen2 %!test block.
Rik <rik@octave.org>
parents:
17951
diff
changeset
|
270 Note that @code{popen2}, unlike @code{popen}, will not @nospell{\"reap\"} the\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
271 child process. If you don't use @code{waitpid} to check the child's\n\ |
9564 | 272 exit status, it will linger until Octave exits.\n\ |
17968
43c199e83ed7
Reap child process in popen2 %!test block.
Rik <rik@octave.org>
parents:
17951
diff
changeset
|
273 @seealso{popen, waitpid}\n\ |
6321 | 274 @end deftypefn") |
275 { | |
276 octave_value_list retval; | |
277 | |
278 retval(2) = -1; | |
279 retval(1) = Matrix (); | |
280 retval(0) = Matrix (); | |
281 | |
282 int nargin = args.length (); | |
283 | |
284 if (nargin >= 1 && nargin <= 3) | |
285 { | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
286 std::string exec_file = args(0).xstring_value ("popen2: COMMAND argument must be a string"); |
6321 | 287 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
288 string_vector arg_list; |
6321 | 289 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
290 if (nargin >= 2) |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
291 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
292 string_vector tmp = args(1).xall_strings ("popen2: all arguments must be strings"); |
6321 | 293 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
294 int len = tmp.numel (); |
6321 | 295 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
296 arg_list.resize (len + 1); |
6321 | 297 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
298 arg_list[0] = exec_file; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
299 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
300 for (int i = 0; i < len; i++) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
301 arg_list[i+1] = tmp[i]; |
6321 | 302 } |
303 else | |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
304 { |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
305 arg_list.resize (1); |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
306 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
307 arg_list[0] = exec_file; |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
308 } |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
309 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
310 bool sync_mode = (nargin == 3 ? args(2).bool_value () : false); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
311 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
312 int fildes[2]; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
313 std::string msg; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
314 pid_t pid; |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
315 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
316 pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode, |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
317 fildes, msg, interactive); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
318 if (pid >= 0) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
319 { |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
320 FILE *ifile = fdopen (fildes[1], "r"); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
321 FILE *ofile = fdopen (fildes[0], "w"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
322 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
323 std::string nm; |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
324 |
20764
0ad449bc8848
Stop 'fclose ("all")' from closing down gnuplot pipes (bug #39504).
Rik <rik@octave.org>
parents:
20741
diff
changeset
|
325 octave_stream is = octave_stdiostream::create (exec_file + "-in", |
0ad449bc8848
Stop 'fclose ("all")' from closing down gnuplot pipes (bug #39504).
Rik <rik@octave.org>
parents:
20741
diff
changeset
|
326 ifile, |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
327 std::ios::in); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
328 |
20764
0ad449bc8848
Stop 'fclose ("all")' from closing down gnuplot pipes (bug #39504).
Rik <rik@octave.org>
parents:
20741
diff
changeset
|
329 octave_stream os = octave_stdiostream::create (exec_file + "-out", |
0ad449bc8848
Stop 'fclose ("all")' from closing down gnuplot pipes (bug #39504).
Rik <rik@octave.org>
parents:
20741
diff
changeset
|
330 ofile, |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
331 std::ios::out); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
332 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
333 Cell file_ids (1, 2); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
334 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
335 retval(2) = pid; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
336 retval(1) = octave_stream_list::insert (is); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
337 retval(0) = octave_stream_list::insert (os); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
338 } |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
339 else |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
340 error (msg.c_str ()); |
6321 | 341 } |
342 else | |
343 print_usage (); | |
344 | |
345 return retval; | |
346 } | |
347 | |
348 /* | |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
349 |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
350 %!test # UNIX-style test |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
351 %! if (isunix () || ismac ()) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
352 %! [in, out, pid] = popen2 ("sort", "-r"); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
353 %! EAGAIN = errno ("EAGAIN"); |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
354 %! fputs (in, "these\nare\nsome\nstrings\n"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
355 %! fclose (in); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
356 %! done = false; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
357 %! str = {}; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
358 %! idx = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
359 %! errs = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
360 %! do |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
361 %! if (ismac ()) # FIXME: Is this necessary? |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
362 %! errno (0); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
363 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
364 %! s = fgets (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
365 %! if (ischar (s)) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
366 %! idx++; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
367 %! str{idx} = s; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
368 %! elseif (errno () == EAGAIN) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
369 %! fclear (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
370 %! sleep (0.1); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
371 %! if (++errs == 100) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
372 %! done = true; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
373 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
374 %! else |
6321 | 375 %! done = true; |
376 %! endif | |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
377 %! until (done) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
378 %! fclose (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
379 %! waitpid (pid); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
380 %! assert (str, {"these\n","strings\n","some\n","are\n"}); |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
381 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
382 |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
383 %!test # Windows-style test |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
384 %! if (ispc () && ! isunix ()) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
385 %! [in, out, pid] = popen2 ('C:\Windows\system32\sort.exe', "/R"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
386 %! EAGAIN = errno ("EINVAL"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
387 %! fputs (in, "these\r\nare\r\nsome\r\nstrings\r\n"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
388 %! fclose (in); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
389 %! done = false; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
390 %! str = {}; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
391 %! idx = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
392 %! errs = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
393 %! do |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
394 %! errno (0); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
395 %! s = fgets (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
396 %! if (ischar (s)) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
397 %! idx++; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
398 %! str{idx} = s; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
399 %! elseif (errno () == EAGAIN) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
400 %! fclear (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
401 %! sleep (0.1); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
402 %! if (++errs == 100) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
403 %! done = true; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
404 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
405 %! else |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
406 %! done = true; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
407 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
408 %! until (done) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
409 %! fclose (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
410 %! waitpid (pid); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
411 %! 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
|
412 %! endif |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
413 |
6321 | 414 */ |
415 | |
10259 | 416 DEFUNX ("fcntl", Ffcntl, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
417 "-*- texinfo -*-\n\ |
3301 | 418 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})\n\ |
19109
e90bfaadb489
doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents:
18112
diff
changeset
|
419 Change the properties of the open file @var{fid}.\n\ |
e90bfaadb489
doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents:
18112
diff
changeset
|
420 \n\ |
e90bfaadb489
doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents:
18112
diff
changeset
|
421 The following values may be passed as @var{request}:\n\ |
3301 | 422 \n\ |
423 @vtable @code\n\ | |
424 @item F_DUPFD\n\ | |
425 Return a duplicate file descriptor.\n\ | |
426 \n\ | |
427 @item F_GETFD\n\ | |
428 Return the file descriptor flags for @var{fid}.\n\ | |
429 \n\ | |
430 @item F_SETFD\n\ | |
431 Set the file descriptor flags for @var{fid}.\n\ | |
432 \n\ | |
433 @item F_GETFL\n\ | |
434 Return the file status flags for @var{fid}. The following codes may be\n\ | |
435 returned (some of the flags may be undefined on some systems).\n\ | |
436 \n\ | |
437 @vtable @code\n\ | |
438 @item O_RDONLY\n\ | |
439 Open for reading only.\n\ | |
440 \n\ | |
441 @item O_WRONLY\n\ | |
442 Open for writing only.\n\ | |
2669 | 443 \n\ |
3301 | 444 @item O_RDWR\n\ |
445 Open for reading and writing.\n\ | |
446 \n\ | |
447 @item O_APPEND\n\ | |
448 Append on each write.\n\ | |
449 \n\ | |
5040 | 450 @item O_CREAT\n\ |
451 Create the file if it does not exist.\n\ | |
452 \n\ | |
3301 | 453 @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
|
454 Non-blocking mode.\n\ |
3301 | 455 \n\ |
456 @item O_SYNC\n\ | |
457 Wait for writes to complete.\n\ | |
2669 | 458 \n\ |
3301 | 459 @item O_ASYNC\n\ |
460 Asynchronous I/O.\n\ | |
461 @end vtable\n\ | |
462 \n\ | |
463 @item F_SETFL\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
464 Set the file status flags for @var{fid} to the value specified by @var{arg}.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
465 The only flags that can be changed are @w{@code{O_APPEND}} and\n\ |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
466 @w{@code{O_NONBLOCK}}.\n\ |
3301 | 467 @end vtable\n\ |
468 \n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
469 If successful, @var{err} is 0 and @var{msg} is an empty string. Otherwise,\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
470 @var{err} is nonzero and @var{msg} contains a system-dependent error\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
471 message.\n\ |
19109
e90bfaadb489
doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents:
18112
diff
changeset
|
472 @seealso{fopen, dup2}\n\ |
3301 | 473 @end deftypefn") |
2075 | 474 { |
2669 | 475 octave_value_list retval; |
476 | |
3523 | 477 retval(1) = std::string (); |
4294 | 478 retval(0) = -1; |
2075 | 479 |
480 int nargin = args.length (); | |
481 | |
482 if (nargin == 3) | |
483 { | |
18112
b560bac0fca2
maint: Don't use space between 'args' and '(' when doing indexing.
Rik <rik@octave.org>
parents:
18022
diff
changeset
|
484 octave_stream strm = octave_stream_list::lookup (args(0), "fcntl"); |
2075 | 485 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
486 int fid = strm.file_number (); |
3715 | 487 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
488 int req = args(1).int_value (true); |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
489 int arg = args(2).int_value (true); |
3715 | 490 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
491 // FIXME: Need better checking here? |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
492 if (fid < 0) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
493 error ("fcntl: invalid file id"); |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
494 else |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
495 { |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
496 std::string msg; |
2937 | 497 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
498 int status = octave_fcntl (fid, req, arg, msg); |
2669 | 499 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
500 retval(1) = msg; |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
501 retval(0) = status; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
502 } |
2075 | 503 } |
504 else | |
5823 | 505 print_usage (); |
2075 | 506 |
507 return retval; | |
508 } | |
509 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
510 DEFUNX ("fork", Ffork, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
511 "-*- texinfo -*-\n\ |
3301 | 512 @deftypefn {Built-in Function} {[@var{pid}, @var{msg}] =} fork ()\n\ |
2669 | 513 Create a copy of the current process.\n\ |
514 \n\ | |
3301 | 515 Fork can return one of the following values:\n\ |
516 \n\ | |
517 @table @asis\n\ | |
518 @item > 0\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
519 You are in the parent process. The value returned from @code{fork} is the\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
520 process id of the child process. You should probably arrange to wait for\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
521 any child processes to exit.\n\ |
3301 | 522 \n\ |
523 @item 0\n\ | |
524 You are in the child process. You can call @code{exec} to start another\n\ | |
525 process. If that fails, you should probably call @code{exit}.\n\ | |
526 \n\ | |
527 @item < 0\n\ | |
528 The call to @code{fork} failed for some reason. You must take evasive\n\ | |
529 action. A system dependent error message will be waiting in @var{msg}.\n\ | |
530 @end table\n\ | |
531 @end deftypefn") | |
2075 | 532 { |
2669 | 533 octave_value_list retval; |
534 | |
3523 | 535 retval(1) = std::string (); |
4294 | 536 retval(0) = -1; |
2075 | 537 |
538 int nargin = args.length (); | |
539 | |
540 if (nargin == 0) | |
2475 | 541 { |
3523 | 542 std::string msg; |
2937 | 543 |
544 pid_t pid = octave_syscalls::fork (msg); | |
2669 | 545 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
546 retval(1) = msg; |
4233 | 547 retval(0) = pid; |
2475 | 548 } |
2075 | 549 else |
5823 | 550 print_usage (); |
2075 | 551 |
552 return retval; | |
553 } | |
554 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
555 DEFUNX ("getpgrp", Fgetpgrp, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
556 "-*- texinfo -*-\n\ |
3301 | 557 @deftypefn {Built-in Function} {pgid =} getpgrp ()\n\ |
558 Return the process group id of the current process.\n\ | |
559 @end deftypefn") | |
2075 | 560 { |
2937 | 561 octave_value_list retval; |
562 | |
3523 | 563 retval(1) = std::string (); |
4294 | 564 retval(0) = -1; |
2075 | 565 |
566 int nargin = args.length (); | |
567 | |
568 if (nargin == 0) | |
2475 | 569 { |
3523 | 570 std::string msg; |
2937 | 571 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
572 retval(1) = msg; |
4233 | 573 retval(0) = octave_syscalls::getpgrp (msg); |
2475 | 574 } |
2075 | 575 else |
5823 | 576 print_usage (); |
2075 | 577 |
578 return retval; | |
579 } | |
580 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
581 DEFUNX ("getpid", Fgetpid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
582 "-*- texinfo -*-\n\ |
3301 | 583 @deftypefn {Built-in Function} {pid =} getpid ()\n\ |
584 Return the process id of the current process.\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
585 @seealso{getppid}\n\ |
3301 | 586 @end deftypefn") |
2075 | 587 { |
4233 | 588 octave_value retval = -1; |
2075 | 589 |
590 int nargin = args.length (); | |
591 | |
592 if (nargin == 0) | |
2937 | 593 retval = octave_syscalls::getpid (); |
2075 | 594 else |
5823 | 595 print_usage (); |
2075 | 596 |
597 return retval; | |
598 } | |
599 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
600 DEFUNX ("getppid", Fgetppid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
601 "-*- texinfo -*-\n\ |
3301 | 602 @deftypefn {Built-in Function} {pid =} getppid ()\n\ |
603 Return the process id of the parent process.\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
604 @seealso{getpid}\n\ |
3301 | 605 @end deftypefn") |
2075 | 606 { |
4233 | 607 octave_value retval = -1; |
2075 | 608 |
2475 | 609 int nargin = args.length (); |
610 | |
611 if (nargin == 0) | |
2937 | 612 retval = octave_syscalls::getppid (); |
2475 | 613 else |
5823 | 614 print_usage (); |
2475 | 615 |
616 return retval; | |
617 } | |
618 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
619 DEFUNX ("getegid", Fgetegid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
620 "-*- texinfo -*-\n\ |
3301 | 621 @deftypefn {Built-in Function} {egid =} getegid ()\n\ |
622 Return the effective group id of the current process.\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
623 @seealso{getgid}\n\ |
3301 | 624 @end deftypefn") |
2475 | 625 { |
4233 | 626 octave_value retval = -1; |
2475 | 627 |
2075 | 628 int nargin = args.length (); |
629 | |
630 if (nargin == 0) | |
4254 | 631 retval = octave_syscalls::getegid (); |
2075 | 632 else |
5823 | 633 print_usage (); |
2475 | 634 |
635 return retval; | |
636 } | |
637 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
638 DEFUNX ("getgid", Fgetgid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
639 "-*- texinfo -*-\n\ |
3301 | 640 @deftypefn {Built-in Function} {gid =} getgid ()\n\ |
641 Return the real group id of the current process.\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
642 @seealso{getegid}\n\ |
3301 | 643 @end deftypefn") |
2475 | 644 { |
4233 | 645 octave_value retval = -1; |
2475 | 646 |
647 int nargin = args.length (); | |
648 | |
649 if (nargin == 0) | |
4254 | 650 retval = octave_syscalls::getgid (); |
2475 | 651 else |
5823 | 652 print_usage (); |
2075 | 653 |
654 return retval; | |
655 } | |
656 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
657 DEFUNX ("geteuid", Fgeteuid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
658 "-*- texinfo -*-\n\ |
3301 | 659 @deftypefn {Built-in Function} {euid =} geteuid ()\n\ |
660 Return the effective user id of the current process.\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
661 @seealso{getuid}\n\ |
3301 | 662 @end deftypefn") |
2472 | 663 { |
4233 | 664 octave_value retval = -1; |
2472 | 665 |
666 int nargin = args.length (); | |
667 | |
668 if (nargin == 0) | |
4254 | 669 retval = octave_syscalls::geteuid (); |
2472 | 670 else |
5823 | 671 print_usage (); |
2473 | 672 |
673 return retval; | |
2472 | 674 } |
675 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
676 DEFUNX ("getuid", Fgetuid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
677 "-*- texinfo -*-\n\ |
3301 | 678 @deftypefn {Built-in Function} {uid =} getuid ()\n\ |
679 Return the real user id of the current process.\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
680 @seealso{geteuid}\n\ |
3301 | 681 @end deftypefn") |
2472 | 682 { |
4233 | 683 octave_value retval = -1; |
2472 | 684 |
685 int nargin = args.length (); | |
686 | |
687 if (nargin == 0) | |
4254 | 688 retval = octave_syscalls::getuid (); |
2472 | 689 else |
5823 | 690 print_usage (); |
2473 | 691 |
692 return retval; | |
2472 | 693 } |
694 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
695 DEFUNX ("kill", Fkill, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
696 "-*- texinfo -*-\n\ |
4294 | 697 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} kill (@var{pid}, @var{sig})\n\ |
698 Send signal @var{sig} to process @var{pid}.\n\ | |
699 \n\ | |
700 If @var{pid} is positive, then signal @var{sig} is sent to @var{pid}.\n\ | |
701 \n\ | |
702 If @var{pid} is 0, then signal @var{sig} is sent to every process\n\ | |
703 in the process group of the current process.\n\ | |
704 \n\ | |
705 If @var{pid} is -1, then signal @var{sig} is sent to every process\n\ | |
706 except process 1.\n\ | |
707 \n\ | |
708 If @var{pid} is less than -1, then signal @var{sig} is sent to every\n\ | |
709 process in the process group @var{-pid}.\n\ | |
710 \n\ | |
4371 | 711 If @var{sig} is 0, then no signal is sent, but error checking is still\n\ |
4294 | 712 performed.\n\ |
713 \n\ | |
7001 | 714 Return 0 if successful, otherwise return -1.\n\ |
4294 | 715 @end deftypefn") |
716 { | |
717 octave_value_list retval; | |
718 | |
719 retval(1) = std::string (); | |
720 retval(0) = -1; | |
721 | |
722 if (args.length () == 2) | |
723 { | |
724 pid_t pid = args(0).int_value (true); | |
725 | |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
726 int sig = args(1).int_value (true); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
727 |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
728 std::string msg; |
4294 | 729 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
730 int status = octave_syscalls::kill (pid, sig, msg); |
4294 | 731 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
732 retval(1) = msg; |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
733 retval(0) = status; |
4294 | 734 } |
735 else | |
5823 | 736 print_usage (); |
4294 | 737 |
738 return retval; | |
739 } | |
740 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
741 DEFUNX ("lstat", Flstat, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
742 "-*- texinfo -*-\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
743 @deftypefn {Built-in Function} {@var{info} =} lstat (@var{symlink})\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
744 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
745 Return a structure @var{info} containing information about the symbolic link\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
746 @var{symlink}.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
747 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
748 The function outputs are described in the documentation for @code{stat}.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
749 @seealso{stat, symlink}\n\ |
3458 | 750 @end deftypefn") |
2075 | 751 { |
2263 | 752 octave_value_list retval; |
2075 | 753 |
754 if (args.length () == 1) | |
755 { | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
756 std::string fname = args(0).xstring_value ("lstat: NAME must be a string"); |
2075 | 757 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
758 file_stat fs (fname, false); |
2075 | 759 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
760 retval = mk_stat_result (fs); |
2075 | 761 } |
762 else | |
5823 | 763 print_usage (); |
2075 | 764 |
765 return retval; | |
766 } | |
767 | |
20200
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
768 // FIXME: This routine also exists verbatim in file-io.cc. |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
769 // Maybe change to be a general utility routine. |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
770 static int |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
771 convert (int x, int ibase, int obase) |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
772 { |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
773 int retval = 0; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
774 |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
775 int tmp = x % obase; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
776 |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
777 if (tmp > ibase - 1) |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
778 error ("mkfifo: invalid digit"); |
20200
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
779 else |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
780 { |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
781 retval = tmp; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
782 int mult = ibase; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
783 while ((x = (x - tmp) / obase)) |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
784 { |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
785 tmp = x % obase; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
786 if (tmp > ibase - 1) |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
787 { |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
788 error ("mkfifo: invalid digit"); |
20200
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
789 break; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
790 } |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
791 retval += mult * tmp; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
792 mult *= ibase; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
793 } |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
794 } |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
795 |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
796 return retval; |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
797 } |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
798 |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
799 DEFUNX ("mkfifo", Fmkfifo, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
800 "-*- texinfo -*-\n\ |
20198
b597bd161a5f
doc: Document that mkfifo's mode argument is in decimal (bug #45054).
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
801 @deftypefn {Built-in Function} {@var{err} =} mkfifo (@var{name}, @var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
802 @deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ |
20198
b597bd161a5f
doc: Document that mkfifo's mode argument is in decimal (bug #45054).
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
803 Create a FIFO special file named @var{name} with file mode @var{mode}.\n\ |
b597bd161a5f
doc: Document that mkfifo's mode argument is in decimal (bug #45054).
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
804 \n\ |
20200
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
805 @var{mode} is interpreted as an octal number and is subject to umask\n\ |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
806 processing. The final calculated mode is @code{@var{mode} - @var{umask}}.\n\ |
2075 | 807 \n\ |
3301 | 808 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
809 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
810 error message.\n\ |
20198
b597bd161a5f
doc: Document that mkfifo's mode argument is in decimal (bug #45054).
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
811 @seealso{pipe, umask}\n\ |
3301 | 812 @end deftypefn") |
2075 | 813 { |
20200
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
814 octave_value_list retval (2); |
2669 | 815 |
3523 | 816 retval(1) = std::string (); |
4294 | 817 retval(0) = -1; |
2075 | 818 |
819 int nargin = args.length (); | |
820 | |
821 if (nargin == 2) | |
822 { | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
823 std::string name = args(0).xstring_value ("mkfifo: FILE must be a string"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
824 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
825 int octal_mode = args(1).xint_value ("mkfifo: MODE must be an integer"); |
2075 | 826 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
827 if (octal_mode < 0) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
828 error ("mkfifo: MODE must be a positive integer value"); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
829 else |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
830 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
831 int mode = convert (octal_mode, 8, 10); |
4254 | 832 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
833 std::string msg; |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
834 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
835 int status = octave_mkfifo (name, mode, msg); |
20200
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
836 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
837 retval(0) = status; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
838 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
839 if (status < 0) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
840 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
841 } |
2075 | 842 } |
843 else | |
5823 | 844 print_usage (); |
2075 | 845 |
846 return retval; | |
847 } | |
848 | |
20200
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
849 /* |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
850 |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
851 ## Test input validation |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
852 %!error mkfifo () |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
853 %!error mkfifo ("abc") |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
854 %!error mkfifo ("abc", 777, 123) |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
855 %!error <FILE must be a string> mkfifo (123, 456) |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
856 ## FIXME: These tests should work, but lasterr is not being set correctly. |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
857 #%!error <MODE must be an integer> mkfifo ("abc", {456}) |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
858 #%!error <MODE must be a positive integer value> mkfifo ("abc", -1) |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
859 |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
860 */ |
d9f35ceff9e1
Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents:
20198
diff
changeset
|
861 |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
862 DEFUNX ("pipe", Fpipe, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
863 "-*- texinfo -*-\n\ |
6321 | 864 @deftypefn {Built-in Function} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
865 Create a pipe and return the reading and writing ends of the pipe into\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
866 @var{read_fd} and @var{write_fd} respectively.\n\ |
2669 | 867 \n\ |
3301 | 868 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
869 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
870 error message.\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
871 @seealso{mkfifo}\n\ |
3301 | 872 @end deftypefn") |
2075 | 873 { |
2669 | 874 octave_value_list retval; |
875 | |
6321 | 876 retval(3) = std::string (); |
877 retval(2) = -1; | |
4294 | 878 retval(1) = -1; |
6321 | 879 retval(0) = -1; |
2075 | 880 |
881 int nargin = args.length (); | |
882 | |
883 if (nargin == 0) | |
884 { | |
885 int fid[2]; | |
886 | |
3523 | 887 std::string msg; |
2937 | 888 |
889 int status = octave_syscalls::pipe (fid, msg); | |
2669 | 890 |
891 if (status < 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
892 retval(3) = msg; |
2669 | 893 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
894 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
895 FILE *ifile = fdopen (fid[0], "r"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
896 FILE *ofile = fdopen (fid[1], "w"); |
2075 | 897 |
20764
0ad449bc8848
Stop 'fclose ("all")' from closing down gnuplot pipes (bug #39504).
Rik <rik@octave.org>
parents:
20741
diff
changeset
|
898 octave_stream is = octave_stdiostream::create ("pipe-in", ifile, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
899 std::ios::in); |
4327 | 900 |
20764
0ad449bc8848
Stop 'fclose ("all")' from closing down gnuplot pipes (bug #39504).
Rik <rik@octave.org>
parents:
20741
diff
changeset
|
901 octave_stream os = octave_stdiostream::create ("pipe-out", ofile, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
902 std::ios::out); |
2075 | 903 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
904 retval(2) = status; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
905 retval(1) = octave_stream_list::insert (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
906 retval(0) = octave_stream_list::insert (is); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
907 } |
2075 | 908 } |
909 else | |
5823 | 910 print_usage (); |
2075 | 911 |
912 return retval; | |
913 } | |
914 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
915 DEFUNX ("stat", Fstat, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
916 "-*- texinfo -*-\n\ |
10840 | 917 @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
|
918 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{fid})\n\ |
3301 | 919 @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
|
920 @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
|
921 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
|
922 @var{file} or file identifier @var{fid}.\n\ |
3301 | 923 \n\ |
924 @table @code\n\ | |
925 @item dev\n\ | |
926 ID of device containing a directory entry for this file.\n\ | |
927 \n\ | |
928 @item ino\n\ | |
929 File number of the file.\n\ | |
930 \n\ | |
5476 | 931 @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
|
932 File mode, as an integer. Use the functions @w{@code{S_ISREG}},\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17236
diff
changeset
|
933 @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:
17236
diff
changeset
|
934 @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:
17236
diff
changeset
|
935 information from this value.\n\ |
5476 | 936 \n\ |
3301 | 937 @item modestr\n\ |
938 File mode, as a string of ten letters or dashes as would be returned by\n\ | |
939 @kbd{ls -l}.\n\ | |
940 \n\ | |
941 @item nlink\n\ | |
942 Number of links.\n\ | |
2075 | 943 \n\ |
3301 | 944 @item uid\n\ |
945 User ID of file's owner.\n\ | |
946 \n\ | |
947 @item gid\n\ | |
948 Group ID of file's group.\n\ | |
949 \n\ | |
950 @item rdev\n\ | |
951 ID of device for block or character special files.\n\ | |
952 \n\ | |
953 @item size\n\ | |
954 Size in bytes.\n\ | |
955 \n\ | |
956 @item atime\n\ | |
957 Time of last access in the same form as time values returned from\n\ | |
958 @code{time}. @xref{Timing Utilities}.\n\ | |
959 \n\ | |
960 @item mtime\n\ | |
961 Time of last modification in the same form as time values returned from\n\ | |
962 @code{time}. @xref{Timing Utilities}.\n\ | |
2075 | 963 \n\ |
3301 | 964 @item ctime\n\ |
965 Time of last file status change in the same form as time values\n\ | |
966 returned from @code{time}. @xref{Timing Utilities}.\n\ | |
967 \n\ | |
968 @item blksize\n\ | |
969 Size of blocks in the file.\n\ | |
970 \n\ | |
971 @item blocks\n\ | |
972 Number of blocks allocated for file.\n\ | |
973 @end table\n\ | |
974 \n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
975 If the call is successful @var{err} is 0 and @var{msg} is an empty string.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
976 If the file does not exist, or some other error occurs, @var{info} is an\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
977 empty matrix, @var{err} is @minus{}1, and @var{msg} contains the\n\ |
3301 | 978 corresponding system error message.\n\ |
979 \n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
980 If @var{file} is a symbolic link, @code{stat} will return information about\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
981 the actual file that is referenced by the link. Use @code{lstat} if you\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
982 want information about the symbolic link itself.\n\ |
3301 | 983 \n\ |
10840 | 984 For example:\n\ |
2075 | 985 \n\ |
3301 | 986 @example\n\ |
15065
f7215831fe78
doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents:
14861
diff
changeset
|
987 [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
|
988 @result{} info =\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
989 @{\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
990 atime = 855399756\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
991 rdev = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
992 ctime = 847219094\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
993 uid = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
994 size = 389218\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
995 blksize = 4096\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
996 mtime = 847219094\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
997 gid = 6\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
998 nlink = 1\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
999 blocks = 768\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1000 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
|
1001 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
|
1002 ino = 9316\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1003 dev = 2049\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1004 @}\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1005 @result{} err = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1006 @result{} msg =\n\ |
3301 | 1007 @end example\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1008 @seealso{lstat, ls, dir}\n\ |
3301 | 1009 @end deftypefn") |
2075 | 1010 { |
2262 | 1011 octave_value_list retval; |
2075 | 1012 |
1013 if (args.length () == 1) | |
1014 { | |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1015 if (args(0).is_scalar_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1016 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1017 int fid = octave_stream_list::get_file_number (args(0)); |
2075 | 1018 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1019 file_fstat fs (fid); |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1020 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1021 retval = mk_stat_result (fs); |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1022 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1023 else |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1024 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
1025 std::string fname = args(0).xstring_value ("stat: NAME must be a string"); |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1026 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1027 file_stat fs (fname); |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1028 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1029 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1030 } |
2075 | 1031 } |
1032 else | |
5823 | 1033 print_usage (); |
2075 | 1034 |
1035 return retval; | |
1036 } | |
1037 | |
5476 | 1038 DEFUNX ("S_ISREG", FS_ISREG, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1039 "-*- texinfo -*-\n\ |
5476 | 1040 @deftypefn {Built-in Function} {} S_ISREG (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1041 Return true if @var{mode} corresponds to a regular file.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1042 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1043 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1044 @seealso{stat, lstat}\n\ |
1045 @end deftypefn") | |
1046 { | |
1047 octave_value retval = false; | |
1048 | |
1049 if (args.length () == 1) | |
1050 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1051 double mode = args(0).xdouble_value ("S_ISREG: invalid MODE value"); |
5476 | 1052 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1053 retval = file_stat::is_reg (static_cast<mode_t> (mode)); |
5476 | 1054 } |
1055 else | |
5823 | 1056 print_usage (); |
5476 | 1057 |
1058 return retval; | |
1059 } | |
1060 | |
1061 DEFUNX ("S_ISDIR", FS_ISDIR, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1062 "-*- texinfo -*-\n\ |
5476 | 1063 @deftypefn {Built-in Function} {} S_ISDIR (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1064 Return true if @var{mode} corresponds to a directory.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1065 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1066 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1067 @seealso{stat, lstat}\n\ |
1068 @end deftypefn") | |
1069 { | |
1070 octave_value retval = false; | |
1071 | |
1072 if (args.length () == 1) | |
1073 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1074 double mode = args(0).xdouble_value ("S_ISDIR: invalid MODE value"); |
5476 | 1075 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1076 retval = file_stat::is_dir (static_cast<mode_t> (mode)); |
5476 | 1077 } |
1078 else | |
5823 | 1079 print_usage (); |
5476 | 1080 |
1081 return retval; | |
1082 } | |
1083 | |
1084 DEFUNX ("S_ISCHR", FS_ISCHR, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1085 "-*- texinfo -*-\n\ |
5476 | 1086 @deftypefn {Built-in Function} {} S_ISCHR (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1087 Return true if @var{mode} corresponds to a character device.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1088 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1089 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1090 @seealso{stat, lstat}\n\ |
1091 @end deftypefn") | |
1092 { | |
1093 octave_value retval = false; | |
1094 | |
1095 if (args.length () == 1) | |
1096 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1097 double mode = args(0).xdouble_value ("S_ISCHR: invalid MODE value"); |
5476 | 1098 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1099 retval = file_stat::is_chr (static_cast<mode_t> (mode)); |
5476 | 1100 } |
1101 else | |
5823 | 1102 print_usage (); |
5476 | 1103 |
1104 return retval; | |
1105 } | |
1106 | |
1107 DEFUNX ("S_ISBLK", FS_ISBLK, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1108 "-*- texinfo -*-\n\ |
5476 | 1109 @deftypefn {Built-in Function} {} S_ISBLK (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1110 Return true if @var{mode} corresponds to a block device.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1111 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1112 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1113 @seealso{stat, lstat}\n\ |
1114 @end deftypefn") | |
1115 { | |
1116 octave_value retval = false; | |
1117 | |
1118 if (args.length () == 1) | |
1119 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1120 double mode = args(0).xdouble_value ("S_ISBLK: invalid MODE value"); |
5476 | 1121 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1122 retval = file_stat::is_blk (static_cast<mode_t> (mode)); |
5476 | 1123 } |
1124 else | |
5823 | 1125 print_usage (); |
5476 | 1126 |
1127 return retval; | |
1128 } | |
1129 | |
1130 DEFUNX ("S_ISFIFO", FS_ISFIFO, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1131 "-*- texinfo -*-\n\ |
5476 | 1132 @deftypefn {Built-in Function} {} S_ISFIFO (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1133 Return true if @var{mode} corresponds to a fifo.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1134 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1135 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1136 @seealso{stat, lstat}\n\ |
1137 @end deftypefn") | |
1138 { | |
1139 octave_value retval = false; | |
1140 | |
1141 if (args.length () == 1) | |
1142 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1143 double mode = args(0).xdouble_value ("S_ISFIFO: invalid MODE value"); |
5476 | 1144 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1145 retval = file_stat::is_fifo (static_cast<mode_t> (mode)); |
5476 | 1146 } |
1147 else | |
5823 | 1148 print_usage (); |
5476 | 1149 |
1150 return retval; | |
1151 } | |
1152 | |
1153 DEFUNX ("S_ISLNK", FS_ISLNK, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1154 "-*- texinfo -*-\n\ |
5476 | 1155 @deftypefn {Built-in Function} {} S_ISLNK (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1156 Return true if @var{mode} corresponds to a symbolic link.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1157 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1158 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1159 @seealso{stat, lstat}\n\ |
1160 @end deftypefn") | |
1161 { | |
1162 octave_value retval = false; | |
1163 | |
1164 if (args.length () == 1) | |
1165 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1166 double mode = args(0).xdouble_value ("S_ISLNK: invalid MODE value"); |
5476 | 1167 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1168 retval = file_stat::is_lnk (static_cast<mode_t> (mode)); |
5476 | 1169 } |
1170 else | |
5823 | 1171 print_usage (); |
5476 | 1172 |
1173 return retval; | |
1174 } | |
1175 | |
1176 DEFUNX ("S_ISSOCK", FS_ISSOCK, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1177 "-*- texinfo -*-\n\ |
5476 | 1178 @deftypefn {Built-in Function} {} S_ISSOCK (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1179 Return true if @var{mode} corresponds to a socket.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1180 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1181 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1182 @seealso{stat, lstat}\n\ |
1183 @end deftypefn") | |
1184 { | |
1185 octave_value retval = false; | |
1186 | |
1187 if (args.length () == 1) | |
1188 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1189 double mode = args(0).xdouble_value ("S_ISSOCK: invalid MODE value"); |
5476 | 1190 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1191 retval = file_stat::is_sock (static_cast<mode_t> (mode)); |
5476 | 1192 } |
1193 else | |
5823 | 1194 print_usage (); |
5476 | 1195 |
1196 return retval; | |
1197 } | |
1198 | |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1199 DEFUN (gethostname, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1200 "-*- texinfo -*-\n\ |
12514
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1201 @deftypefn {Built-in Function} {} gethostname ()\n\ |
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1202 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
|
1203 @end deftypefn") |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1204 { |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1205 octave_value retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1206 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1207 if (args.length () == 0) |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1208 retval = octave_env::get_host_name (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1209 else |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1210 print_usage (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1211 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1212 return retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1213 } |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1214 |
5547 | 1215 DEFUN (uname, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1216 "-*- texinfo -*-\n\ |
5547 | 1217 @deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1218 Return system information in the structure.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1219 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1220 For example:\n\ |
5547 | 1221 \n\ |
1222 @example\n\ | |
1223 @group\n\ | |
1224 uname ()\n\ | |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1225 @result{} @{\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1226 sysname = x86_64\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1227 nodename = segfault\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1228 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
|
1229 version = Linux\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1230 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
|
1231 @}\n\ |
5547 | 1232 @end group\n\ |
1233 @end example\n\ | |
1234 \n\ | |
1235 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ | |
1236 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
1237 system-dependent error message.\n\ | |
1238 @end deftypefn") | |
1239 { | |
1240 octave_value_list retval; | |
1241 | |
1242 if (args.length () == 0) | |
1243 { | |
1244 octave_uname sysinfo; | |
1245 | |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1246 octave_scalar_map m; |
5547 | 1247 |
1248 m.assign ("sysname", sysinfo.sysname ()); | |
1249 m.assign ("nodename", sysinfo.nodename ()); | |
1250 m.assign ("release", sysinfo.release ()); | |
1251 m.assign ("version", sysinfo.version ()); | |
1252 m.assign ("machine", sysinfo.machine ()); | |
1253 | |
1254 retval(2) = sysinfo.message (); | |
1255 retval(1) = sysinfo.error (); | |
1256 retval(0) = m; | |
1257 } | |
1258 else | |
5823 | 1259 print_usage (); |
5547 | 1260 |
1261 return retval; | |
1262 } | |
1263 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1264 DEFUNX ("unlink", Funlink, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1265 "-*- texinfo -*-\n\ |
3301 | 1266 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\ |
1267 Delete the file named @var{file}.\n\ | |
2075 | 1268 \n\ |
3301 | 1269 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1270 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1271 error message.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1272 @seealso{delete, rmdir}\n\ |
3301 | 1273 @end deftypefn") |
2075 | 1274 { |
2669 | 1275 octave_value_list retval; |
1276 | |
3523 | 1277 retval(1) = std::string (); |
4294 | 1278 retval(0) = -1; |
2075 | 1279 |
1280 int nargin = args.length (); | |
1281 | |
1282 if (nargin == 1) | |
1283 { | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
1284 std::string name = args(0).xstring_value ("unlink: FILE must be a string"); |
2075 | 1285 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1286 std::string msg; |
2669 | 1287 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1288 int status = octave_unlink (name, msg); |
2669 | 1289 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1290 retval(1) = msg; |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1291 retval(0) = status; |
2075 | 1292 } |
1293 else | |
5823 | 1294 print_usage (); |
2075 | 1295 |
1296 return retval; | |
1297 } | |
1298 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
1299 DEFUNX ("waitpid", Fwaitpid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1300 "-*- texinfo -*-\n\ |
5453 | 1301 @deftypefn {Built-in Function} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1302 Wait for process @var{pid} to terminate.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1303 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1304 The @var{pid} argument can be:\n\ |
2075 | 1305 \n\ |
3301 | 1306 @table @asis\n\ |
1307 @item @minus{}1\n\ | |
1308 Wait for any child process.\n\ | |
2075 | 1309 \n\ |
3301 | 1310 @item 0\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1311 Wait for any child process whose process group ID is equal to that of the\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1312 Octave interpreter process.\n\ |
2075 | 1313 \n\ |
3301 | 1314 @item > 0\n\ |
1315 Wait for termination of the child process with ID @var{pid}.\n\ | |
1316 @end table\n\ | |
1317 \n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1318 The @var{options} argument can be a bitwise OR of zero or more of the\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1319 following constants:\n\ |
2075 | 1320 \n\ |
5453 | 1321 @table @code\n\ |
3301 | 1322 @item 0\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1323 Wait until signal is received or a child process exits (this is the default\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1324 if the @var{options} argument is missing).\n\ |
3301 | 1325 \n\ |
5453 | 1326 @item WNOHANG\n\ |
3301 | 1327 Do not hang if status is not immediately available.\n\ |
2075 | 1328 \n\ |
5453 | 1329 @item WUNTRACED\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1330 Report the status of any child processes that are stopped, and whose status\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1331 has not yet been reported since they stopped.\n\ |
3301 | 1332 \n\ |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7924
diff
changeset
|
1333 @item WCONTINUE\n\ |
5453 | 1334 Return if a stopped child has been resumed by delivery of @code{SIGCONT}.\n\ |
1335 This value may not be meaningful on all systems.\n\ | |
3301 | 1336 @end table\n\ |
1337 \n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1338 If the returned value of @var{pid} is greater than 0, it is the process ID\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1339 of the child process that exited. If an error occurs, @var{pid} will be\n\ |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
1340 less than zero and @var{msg} will contain a system-dependent error message.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1341 The value of @var{status} contains additional system-dependent information\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1342 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
|
1343 @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}\n\ |
3301 | 1344 @end deftypefn") |
2075 | 1345 { |
2669 | 1346 octave_value_list retval; |
1347 | |
5453 | 1348 retval(2) = std::string (); |
1349 retval(1) = 0; | |
4294 | 1350 retval(0) = -1; |
2075 | 1351 |
1352 int nargin = args.length (); | |
1353 | |
1354 if (nargin == 1 || nargin == 2) | |
1355 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1356 pid_t pid = args(0).xint_value ("waitpid: OPTIONS must be an integer"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1357 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1358 int options = 0; |
2075 | 1359 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1360 if (args.length () == 2) |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1361 options = args(1).xint_value ("waitpid: PID must be an integer value"); |
2937 | 1362 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1363 std::string msg; |
2669 | 1364 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1365 int status = 0; |
3202 | 1366 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1367 pid_t result = octave_syscalls::waitpid (pid, &status, |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1368 options, msg); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1369 |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1370 retval(2) = msg; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1371 retval(1) = status; |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1372 retval(0) = result; |
2075 | 1373 } |
1374 else | |
5823 | 1375 print_usage (); |
2075 | 1376 |
1377 return retval; | |
1378 } | |
1379 | |
5453 | 1380 DEFUNX ("WIFEXITED", FWIFEXITED, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1381 "-*- texinfo -*-\n\ |
5453 | 1382 @deftypefn {Built-in Function} {} WIFEXITED (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1383 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1384 true if the child terminated normally.\n\ |
5453 | 1385 @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ |
5646 | 1386 @end deftypefn") |
5453 | 1387 { |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1388 octave_value retval = false; |
5453 | 1389 |
1390 if (args.length () == 1) | |
1391 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1392 int status = args(0).xint_value ("WIFEXITED: STATUS must be an integer"); |
5453 | 1393 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1394 retval = octave_wait::ifexited (status); |
5453 | 1395 } |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1396 else |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1397 print_usage (); |
5453 | 1398 |
1399 return retval; | |
1400 } | |
1401 | |
1402 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1403 "-*- texinfo -*-\n\ |
5453 | 1404 @deftypefn {Built-in Function} {} WEXITSTATUS (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1405 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1406 the exit status of the child.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1407 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1408 This function should only be employed if @code{WIFEXITED} returned true.\n\ |
5453 | 1409 @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ |
1410 @end deftypefn") | |
1411 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1412 octave_value retval = 0; |
5453 | 1413 |
1414 if (args.length () == 1) | |
1415 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1416 int status = args(0).xint_value ("WEXITSTATUS: STATUS must be an integer"); |
5453 | 1417 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1418 retval = octave_wait::exitstatus (status); |
5453 | 1419 } |
1420 | |
1421 return retval; | |
1422 } | |
1423 | |
1424 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1425 "-*- texinfo -*-\n\ |
5453 | 1426 @deftypefn {Built-in Function} {} WIFSIGNALED (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1427 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1428 true if the child process was terminated by a signal.\n\ |
5453 | 1429 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ |
1430 @end deftypefn") | |
1431 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1432 octave_value retval = false; |
5453 | 1433 |
1434 if (args.length () == 1) | |
1435 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1436 int status = args(0).xint_value ("WIFSIGNALED: STATUS must be an integer"); |
5453 | 1437 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1438 retval = octave_wait::ifsignaled (status); |
5453 | 1439 } |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1440 else |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1441 print_usage (); |
5453 | 1442 |
1443 return retval; | |
1444 } | |
1445 | |
1446 DEFUNX ("WTERMSIG", FWTERMSIG, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1447 "-*- texinfo -*-\n\ |
5453 | 1448 @deftypefn {Built-in Function} {} WTERMSIG (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1449 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1450 the number of the signal that caused the child process to terminate.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1451 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1452 This function should only be employed if @code{WIFSIGNALED} returned true.\n\ |
5453 | 1453 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ |
1454 @end deftypefn") | |
1455 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1456 octave_value retval = 0; |
5453 | 1457 |
1458 if (args.length () == 1) | |
1459 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1460 int status = args(0).xint_value ("WTERMSIG: STATUS must be an integer"); |
5453 | 1461 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1462 retval = octave_wait::termsig (status); |
5453 | 1463 } |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1464 else |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1465 print_usage (); |
5453 | 1466 |
1467 return retval; | |
1468 } | |
1469 | |
1470 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1471 "-*- texinfo -*-\n\ |
5453 | 1472 @deftypefn {Built-in Function} {} WCOREDUMP (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1473 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1474 true if the child produced a core dump.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1475 \n\ |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20172
diff
changeset
|
1476 This function should only be employed if @code{WIFSIGNALED} returned true.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1477 The macro used to implement this function is not specified in POSIX.1-2001\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1478 and is not available on some Unix implementations (e.g., AIX, SunOS).\n\ |
5453 | 1479 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ |
1480 @end deftypefn") | |
1481 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1482 octave_value retval = false; |
5453 | 1483 |
1484 if (args.length () == 1) | |
1485 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1486 int status = args(0).xint_value ("WCOREDUMP: STATUS must be an integer"); |
5453 | 1487 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1488 retval = octave_wait::coredump (status); |
5453 | 1489 } |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1490 else |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1491 print_usage (); |
5453 | 1492 |
1493 return retval; | |
1494 } | |
1495 | |
1496 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1497 "-*- texinfo -*-\n\ |
5453 | 1498 @deftypefn {Built-in Function} {} WIFSTOPPED (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1499 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1500 true if the child process was stopped by delivery of a signal.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1501 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1502 This is only possible if the call was done using @code{WUNTRACED} or when\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1503 the child is being traced (see ptrace(2)).\n\ |
5453 | 1504 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WSTOPSIG, WIFCONTINUED}\n\ |
1505 @end deftypefn") | |
1506 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1507 octave_value retval = false; |
5453 | 1508 |
1509 if (args.length () == 1) | |
1510 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1511 int status = args(0).xint_value ("WIFSTOPPED: STATUS must be an integer"); |
5453 | 1512 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1513 retval = octave_wait::ifstopped (status); |
5453 | 1514 } |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1515 else |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1516 print_usage (); |
5453 | 1517 |
1518 return retval; | |
1519 } | |
1520 | |
1521 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1522 "-*- texinfo -*-\n\ |
5453 | 1523 @deftypefn {Built-in Function} {} WSTOPSIG (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1524 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1525 the number of the signal which caused the child to stop.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1526 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1527 This function should only be employed if @code{WIFSTOPPED} returned true.\n\ |
5453 | 1528 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WIFCONTINUED}\n\ |
1529 @end deftypefn") | |
1530 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1531 octave_value retval = 0; |
5453 | 1532 |
1533 if (args.length () == 1) | |
1534 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1535 int status = args(0).xint_value ("WSTOPSIG: STATUS must be an integer"); |
5453 | 1536 |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1537 retval = octave_wait::stopsig (status); |
5453 | 1538 } |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1539 else |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1540 print_usage (); |
5453 | 1541 |
1542 return retval; | |
1543 } | |
1544 | |
1545 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1546 "-*- texinfo -*-\n\ |
5453 | 1547 @deftypefn {Built-in Function} {} WIFCONTINUED (@var{status})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1548 Given @var{status} from a call to @code{waitpid}, return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1549 true if the child process was resumed by delivery of @code{SIGCONT}.\n\ |
5453 | 1550 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG}\n\ |
1551 @end deftypefn") | |
1552 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1553 octave_value retval = false; |
5453 | 1554 |
1555 if (args.length () == 1) | |
1556 { | |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1557 int status = args(0).xint_value ("WIFCONTINUED: STATUS must be an integer"); |
5453 | 1558 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1559 retval = octave_wait::ifcontinued (status); |
5453 | 1560 } |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1561 else |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1562 print_usage (); |
5453 | 1563 |
1564 return retval; | |
1565 } | |
1566 | |
10249
14eba566f9f0
use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
1567 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1568 "-*- texinfo -*-\n\ |
14819
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1569 @deftypefn {Built-in Function} {[@var{cname}, @var{status}, @var{msg}] =} canonicalize_file_name (@var{fname})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1570 Return the canonical name of file @var{fname}.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1571 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1572 If the file does not exist the empty string (\"\") is returned.\n\ |
14819
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1573 @seealso{make_absolute_filename, is_absolute_filename, is_rooted_relative_filename}\n\ |
5138 | 1574 @end deftypefn") |
1575 { | |
1576 octave_value_list retval; | |
1577 | |
1578 if (args.length () == 1) | |
1579 { | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
1580 std::string name = args(0).xstring_value ("canonicalize_file_name: NAME must be a string"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1581 std::string msg; |
5138 | 1582 |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1583 std::string result = octave_canonicalize_file_name (name, msg); |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1584 |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1585 retval(2) = msg; |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1586 retval(1) = msg.empty () ? 0 : -1; |
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
1587 retval(0) = result; |
5138 | 1588 } |
1589 else | |
5823 | 1590 print_usage (); |
5138 | 1591 |
1592 return retval; | |
1593 } | |
1594 | |
5749 | 1595 static octave_value |
7924 | 1596 const_value (const octave_value_list& args, int val) |
5749 | 1597 { |
1598 octave_value retval; | |
1599 | |
1600 int nargin = args.length (); | |
1601 | |
1602 if (nargin == 0) | |
1603 retval = val; | |
1604 else | |
5823 | 1605 print_usage (); |
5749 | 1606 |
1607 return retval; | |
1608 } | |
1609 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20764
diff
changeset
|
1610 #if ! defined (O_NONBLOCK) && defined (O_NDELAY) |
2075 | 1611 #define O_NONBLOCK O_NDELAY |
1612 #endif | |
1613 | |
5749 | 1614 DEFUNX ("F_DUPFD", FF_DUPFD, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1615 "-*- texinfo -*-\n\ |
5749 | 1616 @deftypefn {Built-in Function} {} F_DUPFD ()\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1617 Return the numerical value to pass to @code{fcntl} to return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1618 a duplicate file descriptor.\n\ |
5749 | 1619 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\ |
1620 @end deftypefn") | |
2075 | 1621 { |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1622 #if defined (F_DUPFD) |
7924 | 1623 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
|
1624 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1625 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
|
1626 return octave_value (); |
2075 | 1627 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1628 } |
2075 | 1629 |
5749 | 1630 DEFUNX ("F_GETFD", FF_GETFD, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1631 "-*- texinfo -*-\n\ |
5749 | 1632 @deftypefn {Built-in Function} {} F_GETFD ()\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1633 Return the numerical value to pass to @code{fcntl} to return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1634 the file descriptor flags.\n\ |
5333 | 1635 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\ |
5749 | 1636 @end deftypefn") |
1637 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1638 #if defined (F_GETFD) |
7924 | 1639 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
|
1640 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1641 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
|
1642 return octave_value (); |
2075 | 1643 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1644 } |
2075 | 1645 |
5749 | 1646 DEFUNX ("F_GETFL", FF_GETFL, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1647 "-*- texinfo -*-\n\ |
5749 | 1648 @deftypefn {Built-in Function} {} F_GETFL ()\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1649 Return the numerical value to pass to @code{fcntl} to return\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1650 the file status flags.\n\ |
5333 | 1651 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\ |
5749 | 1652 @end deftypefn") |
1653 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1654 #if defined (F_GETFL) |
7924 | 1655 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
|
1656 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1657 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
|
1658 return octave_value (); |
2075 | 1659 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1660 } |
2075 | 1661 |
5749 | 1662 DEFUNX ("F_SETFD", FF_SETFD, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1663 "-*- texinfo -*-\n\ |
5749 | 1664 @deftypefn {Built-in Function} {} F_SETFD ()\n\ |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1665 Return the numerical value to pass to @code{fcntl} to set the file\n\ |
5749 | 1666 descriptor flags.\n\ |
5333 | 1667 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\ |
5749 | 1668 @end deftypefn") |
1669 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1670 #if defined (F_SETFD) |
7924 | 1671 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
|
1672 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1673 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
|
1674 return octave_value (); |
2075 | 1675 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1676 } |
2075 | 1677 |
5749 | 1678 DEFUNX ("F_SETFL", FF_SETFL, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1679 "-*- texinfo -*-\n\ |
5749 | 1680 @deftypefn {Built-in Function} {} F_SETFL ()\n\ |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1681 Return the numerical value to pass to @code{fcntl} to set the file\n\ |
5749 | 1682 status flags.\n\ |
5333 | 1683 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\ |
5749 | 1684 @end deftypefn") |
1685 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1686 #if defined (F_SETFL) |
7924 | 1687 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
|
1688 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1689 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
|
1690 return octave_value (); |
2075 | 1691 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1692 } |
2075 | 1693 |
5749 | 1694 DEFUNX ("O_APPEND", FO_APPEND, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1695 "-*- texinfo -*-\n\ |
5749 | 1696 @deftypefn {Built-in Function} {} O_APPEND ()\n\ |
1697 Return the numerical value of the file status flag that may be\n\ | |
1698 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
|
1699 or that may be passed to @code{fcntl} to set the write mode to append.\n\ |
5333 | 1700 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1701 @end deftypefn") |
1702 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1703 #if defined (O_APPEND) |
7924 | 1704 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
|
1705 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1706 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
|
1707 return octave_value (); |
2075 | 1708 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1709 } |
2075 | 1710 |
5749 | 1711 DEFUNX ("O_ASYNC", FO_ASYNC, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1712 "-*- texinfo -*-\n\ |
5749 | 1713 @deftypefn {Built-in Function} {} O_ASYNC ()\n\ |
1714 Return the numerical value of the file status flag that may be\n\ | |
1715 returned by @code{fcntl} to indicate asynchronous I/O.\n\ | |
5333 | 1716 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1717 @end deftypefn") |
1718 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1719 #if defined (O_ASYNC) |
7924 | 1720 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
|
1721 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1722 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
|
1723 return octave_value (); |
2669 | 1724 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1725 } |
2669 | 1726 |
5749 | 1727 DEFUNX ("O_CREAT", FO_CREAT, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1728 "-*- texinfo -*-\n\ |
5749 | 1729 @deftypefn {Built-in Function} {} O_CREAT ()\n\ |
1730 Return the numerical value of the file status flag that may be\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1731 returned by @code{fcntl} to indicate that a file should be created if it\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1732 does not exist.\n\ |
5333 | 1733 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1734 @end deftypefn") |
1735 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1736 #if defined (O_CREAT) |
7924 | 1737 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
|
1738 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1739 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
|
1740 return octave_value (); |
2075 | 1741 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1742 } |
2075 | 1743 |
5749 | 1744 DEFUNX ("O_EXCL", FO_EXCL, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1745 "-*- texinfo -*-\n\ |
5749 | 1746 @deftypefn {Built-in Function} {} O_EXCL ()\n\ |
1747 Return the numerical value of the file status flag that may be\n\ | |
1748 returned by @code{fcntl} to indicate that file locking is used.\n\ | |
5333 | 1749 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1750 @end deftypefn") |
1751 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1752 #if defined (O_EXCL) |
7924 | 1753 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
|
1754 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1755 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
|
1756 return octave_value (); |
2075 | 1757 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1758 } |
2075 | 1759 |
5749 | 1760 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1761 "-*- texinfo -*-\n\ |
5749 | 1762 @deftypefn {Built-in Function} {} O_NONBLOCK ()\n\ |
1763 Return the numerical value of the file status flag that may be\n\ | |
1764 returned by @code{fcntl} to indicate that non-blocking I/O is in use,\n\ | |
1765 or that may be passsed to @code{fcntl} to set non-blocking I/O.\n\ | |
5333 | 1766 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1767 @end deftypefn") |
1768 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1769 #if defined (O_NONBLOCK) |
7924 | 1770 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
|
1771 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1772 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
|
1773 return octave_value (); |
2075 | 1774 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1775 } |
2075 | 1776 |
5749 | 1777 DEFUNX ("O_RDONLY", FO_RDONLY, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1778 "-*- texinfo -*-\n\ |
5749 | 1779 @deftypefn {Built-in Function} {} O_RDONLY ()\n\ |
1780 Return the numerical value of the file status flag that may be\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1781 returned by @code{fcntl} to indicate that a file is open for reading only.\n\ |
5333 | 1782 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1783 @end deftypefn") |
1784 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1785 #if defined (O_RDONLY) |
7924 | 1786 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
|
1787 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1788 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
|
1789 return octave_value (); |
2075 | 1790 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1791 } |
2075 | 1792 |
5749 | 1793 DEFUNX ("O_RDWR", FO_RDWR, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1794 "-*- texinfo -*-\n\ |
5749 | 1795 @deftypefn {Built-in Function} {} O_RDWR ()\n\ |
1796 Return the numerical value of the file status flag that may be\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1797 returned by @code{fcntl} to indicate that a file is open for both reading\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1798 and writing.\n\ |
5333 | 1799 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1800 @end deftypefn") |
1801 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1802 #if defined (O_RDWR) |
7924 | 1803 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
|
1804 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1805 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
|
1806 return octave_value (); |
2075 | 1807 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1808 } |
2075 | 1809 |
5749 | 1810 DEFUNX ("O_SYNC", FO_SYNC, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1811 "-*- texinfo -*-\n\ |
5749 | 1812 @deftypefn {Built-in Function} {} O_SYNC ()\n\ |
1813 Return the numerical value of the file status flag that may be\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1814 returned by @code{fcntl} to indicate that a file is open for synchronous I/O.\n\ |
5333 | 1815 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\ |
5749 | 1816 @end deftypefn") |
1817 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1818 #if defined (O_SYNC) |
7924 | 1819 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
|
1820 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1821 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
|
1822 return octave_value (); |
2669 | 1823 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1824 } |
2669 | 1825 |
5749 | 1826 DEFUNX ("O_TRUNC", FO_TRUNC, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1827 "-*- texinfo -*-\n\ |
19152
0f9c5a15c8fa
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
19109
diff
changeset
|
1828 @deftypefn {Built-in Function} {} O_TRUNC ()\n\ |
5749 | 1829 Return the numerical value of the file status flag that may be\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1830 returned by @code{fcntl} to indicate that if file exists, it should be\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1831 truncated when writing.\n\ |
5333 | 1832 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\ |
5749 | 1833 @end deftypefn") |
1834 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1835 #if defined (O_TRUNC) |
7924 | 1836 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
|
1837 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1838 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
|
1839 return octave_value (); |
2075 | 1840 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1841 } |
2075 | 1842 |
5749 | 1843 DEFUNX ("O_WRONLY", FO_WRONLY, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1844 "-*- texinfo -*-\n\ |
5749 | 1845 @deftypefn {Built-in Function} {} O_WRONLY ()\n\ |
1846 Return the numerical value of the file status flag that may be\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1847 returned by @code{fcntl} to indicate that a file is open for writing only.\n\ |
5333 | 1848 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\ |
5749 | 1849 @end deftypefn") |
1850 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1851 #if defined (O_WRONLY) |
7924 | 1852 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
|
1853 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1854 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
|
1855 return octave_value (); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1856 #endif |
5749 | 1857 } |
3446 | 1858 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20764
diff
changeset
|
1859 #if ! defined (WNOHANG) |
5453 | 1860 #define WNOHANG 0 |
1861 #endif | |
1862 | |
5749 | 1863 DEFUNX ("WNOHANG", FWNOHANG, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1864 "-*- texinfo -*-\n\ |
5749 | 1865 @deftypefn {Built-in Function} {} WNOHANG ()\n\ |
1866 Return the numerical value of the option argument that may be\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1867 passed to @code{waitpid} to indicate that it should return its status\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1868 immediately instead of waiting for a process to exit.\n\ |
5453 | 1869 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\ |
5749 | 1870 @end deftypefn") |
1871 { | |
7924 | 1872 return const_value (args, WNOHANG); |
5749 | 1873 } |
5453 | 1874 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20764
diff
changeset
|
1875 #if ! defined (WUNTRACED) |
5453 | 1876 #define WUNTRACED 0 |
1877 #endif | |
1878 | |
5749 | 1879 DEFUNX ("WUNTRACED", FWUNTRACED, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1880 "-*- texinfo -*-\n\ |
5749 | 1881 @deftypefn {Built-in Function} {} WUNTRACED ()\n\ |
1882 Return the numerical value of the option argument that may be\n\ | |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1883 passed to @code{waitpid} to indicate that it should also return if the child\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1884 process has stopped but is not traced via the @code{ptrace} system call\n\ |
5453 | 1885 @seealso{waitpid, WNOHANG, WCONTINUE}\n\ |
5749 | 1886 @end deftypefn") |
1887 { | |
7924 | 1888 return const_value (args, WUNTRACED); |
5749 | 1889 } |
5453 | 1890 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20764
diff
changeset
|
1891 #if ! defined (WCONTINUE) |
5453 | 1892 #define WCONTINUE 0 |
1893 #endif | |
1894 | |
5749 | 1895 DEFUNX ("WCONTINUE", FWCONTINUE, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1896 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9564
diff
changeset
|
1897 @deftypefn {Built-in Function} {} WCONTINUE ()\n\ |
5749 | 1898 Return the numerical value of the option argument that may be\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1899 passed to @code{waitpid} to indicate that it should also return if a stopped\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1900 child has been resumed by delivery of a @code{SIGCONT} signal.\n\ |
5453 | 1901 @seealso{waitpid, WNOHANG, WUNTRACED}\n\ |
5749 | 1902 @end deftypefn") |
1903 { | |
7924 | 1904 return const_value (args, WCONTINUE); |
2075 | 1905 } |
19109
e90bfaadb489
doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents:
18112
diff
changeset
|
1906 |