0 votes
by Bill Codington (190 points)
Thanks, but still some confusion.

z" qiv /home/pi/VfxForth/Doc/bertie.jpg & echo $!" >pshell

Running this displays the image and prints the PID, but no "ok" until I close the image window.  It works correctly if I use your part of your example:

z" yes > /dev/null & echo $!" >pshell

>system doesn't have this problem.  Something to do with the graphics window?

(feh and sxiv also behave the same)

1 Answer

+1 vote
by Daniel Lee (630 points)

It seems this is by design (and there's a way you can change it).

The word >pShell launches a process, creates a pipe to that process, and sends all standard input to that process until it quits.

Try this:  launch qiv with a list of images using a wildcard like *.jpg.

z" qiv ~/Pictures/*.jpg" >pShell

Then type <space>, <backspace>, q or any other commands from the qiv man page. Notice that they get piped to the program until it quits.

If you want to change this behavior, you could write your own version of >pShell or break it up into its parts.  The code for >pShell is in VFXBase/Lin64/shell.fth on my system.  Notice that it calls popen, caches the pipe's file handle on the return stack, and enters into a loop to send the standard input to the pipe.  You could call popen, stash the file handle somewhere, continue working at the "ok" prompt, and close the pipe when you are done.

See the man page for popen for more info.