From f9490110e156d1cd5221433d3c1f41b0cfab1d01 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Sun, 1 Oct 2023 18:37:40 -0500 Subject: [PATCH] [DOC] Another example for spawn (#8575) --- process.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/process.c b/process.c index 17c8ac4e5f..4f3d72cf68 100644 --- a/process.c +++ b/process.c @@ -4952,18 +4952,24 @@ rb_f_system(int argc, VALUE *argv, VALUE _) * * Argument +exe_path+ is one of the following: * - * - The string path to an executable to be called. + * - The string path to an executable to be called: + * + * spawn('/usr/bin/date') # Path to date on Unix-style system. + * Process.wait + * + * Output: + * + * Thu Aug 31 10:06:48 AM CDT 2023 + * * - A 2-element array containing the path to an executable - * and the string to be used as the name of the executing process. + * and the string to be used as the name of the executing process: * - * Example: + * pid = spawn(['sleep', 'Hello!'], '1') # 2-element array. + * p `ps -p #{pid} -o command=` * - * spawn('/usr/bin/date') # => 799198 # Path to date on Unix-style system. - * Process.wait # => 799198 + * Output: * - * Output: - * - * Thu Aug 31 10:06:48 AM CDT 2023 + * "Hello! 1\n" * * Ruby invokes the executable directly, with no shell and no shell expansion. *