fork-test.stk 1.44 KB
Newer Older
eg's avatar
eg committed
1 2
;;;;
;;;; fork-test.stk	-- A simple program using fork
3 4 5 6
;;;;
;;;; Copyright © 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@essi.fr>
;;;;
;;;;
eg's avatar
eg committed
7 8 9 10
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2 of the License, or
;;;; (at your option) any later version.
11
;;;;
eg's avatar
eg committed
12 13 14 15
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;; GNU General Public License for more details.
16
;;;;
eg's avatar
eg committed
17 18
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
19
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
eg's avatar
eg committed
20
;;;; USA.
21
;;;;
eg's avatar
eg committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
;;;;           Author: Erick Gallesio [eg@essi.fr]
;;;;    Creation date: 10-Jan-2004 15:48 (eg)
;;;; Last file update: 13-Jan-2004 11:26 (eg)
;;;;

(define (main args)
  (let ((proc (fork)))
    (if proc
	(format #t "I'm the parent process. My child pid is ~S\n"
		 (process-pid proc))
	(format #t "I'm the chid process. My process id is ~S\n" (getpid)))

    (format #t "   This text will be printed 2 times\n")

    ;; Wait the end of child ...
    (if proc
	(process-wait proc)
	(exit))

    ;; ... and display a message to finish
    (format #t "This is the last printed line...\n")))