From e9e554e48635a4d62a89c963ca63e4a30c0367ac Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Fri, 11 Jun 2021 20:24:17 +1000 Subject: [PATCH] another example --- examples/fds.f | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 examples/fds.f diff --git a/examples/fds.f b/examples/fds.f new file mode 100755 index 0000000..9211ef0 --- /dev/null +++ b/examples/fds.f @@ -0,0 +1,19 @@ +#!/home/ralph/src/devuan/rrqforth/rrqforth +# +# List file descriptors + +SYSTEM DEFINITIONS + +### using execve +# Prepare empty environment on data stack and save pointer on return stack +0 0 D[n] >R + +# Prepare the arg array on data stack and save pointer on return stack +0 " /proc/self/fd" DROP " -l" DROP " /bin/ls" DROP 0 D[n] >R + +# The program to execute, arguments and environment +" /bin/ls" DROP 0 R[n] @ 1 R[n] @ SYS_EXECVE + +# Shouldn't come here, but in case... +" ERROR" TELL NL EMIT +1 EXIT -- 2.39.2