pike.git/
lib/
modules/
Process.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2004-05-10
2004-05-10 16:55:30 by Martin Nilsson <mani@lysator.liu.se>
eb77b9af220a99332ae1a1a3396e48b936351990 (
24
lines) (+
15
/-
9
)
[
Show
|
Annotate
]
Branch:
7.9
variant in action.
Rev: lib/modules/Process.pmod:1.48
255:
}
+
//! @decl string popen(string command)
+
//! Executes the @[command], waits until it has finished and returns
+
//! the result as a string.
+
+
//! @decl Stdio.FILE popen(string command, string mode)
//! Open a "process" for reading or writing. The @[command] is executed //! as a shell statement ("/bin/sh -c command" for Unix, //! "cmd /c command" for Windows). The parameter @[mode] should
267:
//! Open for writing. Data written to the file is available //! to the process on stdin. //! @endstring
-
//!
If
no
@[
mode
]
is
passed,
read
mode
is
assumed.
-
Stdio.FILE fpopen(string s, string|void mode)
+
+
Stdio.FILE|string
popen(string
s,
string|void
mode
)
{
+
if(mode)
+
return fpopen(s,
mode
);
+
else
+
return fpopen(s)->read();
+
}
+
+
static
Stdio.FILE fpopen(string s, string|void mode)
{
-
if (!mode) mode = "r";
+
Stdio.FILE f = Stdio.FILE(); if (!f) error("Popen failed. (couldn't create file)\n");
287:
return f; }
-
//! Works as @[fpopen], but blocks until the command completes and
-
//! returns the resulting string.
-
string popen(string s) {
-
return fpopen(s)->read();
-
}
-
+
//! int system(string s) {