[plt-scheme] getpid
At Mon, 28 Mar 2005 15:02:48 -0500, "David J. Neu" wrote:
> Would it be possible to have a getpid procedure, that would return the
> process id, included with mzscheme?  I've written a (one procedure)
> mzscheme extension, but I'd prefer not have to carry around and manage
> the installation of the C code.
David beat me to it, but FWIW, here's a version that works with
Windows:
(module getpid mzscheme
  (require (lib "foreign.ss")) (unsafe!)
  (provide getpid)
  (define getpid
    (if (eq? (system-type) 'windows)
	(get-ffi-obj "GetCurrentProcessId" (ffi-lib "kernel32") (_fun -> _int))
	(get-ffi-obj "getpid" #f (_fun -> _int)))))
Matthew