From: Ralph Ronnquist Date: Fri, 11 Jun 2021 10:24:17 +0000 (+1000) Subject: another example X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=e9e554e48635a4d62a89c963ca63e4a30c0367ac;p=rrq%2Frrqforth.git another example --- 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