#lang scheme/base (require scheme/foreign) (unsafe!) (define (display-pass v) (display v)(newline) v) (define (exec prog . args) (define type (_cprocedure (append (list* _string _string (build-list (length args) (λ (i) _string))) (list _pointer)) _int)) (define ffi (get-ffi-obj "execl" #f type)) (apply ffi (find-executable-path prog) (display-pass (cons prog (append args (list #f))))) (error "exec failed!")) (define (main) (exec "echo" "this is" "a test") (error "exec failed!\n")) (provide exec main)