Via Eli on comp.lang.scheme:
#lang scheme
;; using the /proc filesystem
(call-with-input-file "/proc/self/loginuid" read)
;; running `id'
(require scheme/system)
(let ([o (open-output-string)])
(parameterize ([current-output-port o]) (system "id -u"))
(read (open-input-string (get-output-string o))))
;; calling getuid()
(require scheme/foreign)
(unsafe!)
((get-ffi-obj 'getuid #f (_fun -> _int)))