Execing Processes in Lisp
Here’s the translation of the Go code to Lisp, formatted in Markdown suitable for Hugo:
Our example demonstrates how to replace the current process with another one using Lisp. This is similar to the classic exec
function in Unix-like operating systems.
When we run our program, it is replaced by ls
.
Note that Lisp doesn’t offer a classic Unix fork
function either. However, Lisp implementations often provide ways to spawn new processes or execute external programs, which cover most use cases for fork
.
In this example, we’re using Steel Bank Common Lisp (SBCL) and its extensions to achieve functionality similar to the original Go program. The sb-ext:find-executable-in-search-path
function is used to locate the ls
binary, similar to exec.LookPath
in Go. The sb-ext:run-program
function is used to execute the new process, replacing the current one.
Remember that the exact implementation might vary depending on the Lisp implementation you’re using. This example uses SBCL-specific functions, but other Lisp implementations may have different ways to achieve the same result.