GC protection fix for waitpid.

Note that there are probably more bugs similar to this one.
This commit is contained in:
sperber 2002-01-27 20:20:09 +00:00
parent 4406337368
commit 369bc08f2e
1 changed files with 17 additions and 4 deletions

View File

@ -61,13 +61,26 @@ s48_value wait_pid(s48_value s48_pid, s48_value s48_flags)
pid_t pid = (pid_t) s48_extract_integer (s48_pid);
int flags = s48_extract_integer (s48_flags);
pid_t result_pid;
s48_value sch_result_pid = S48_UNSPECIFIC;
s48_value sch_status = S48_UNSPECIFIC;
s48_value sch_status_list = S48_UNSPECIFIC;
s48_value sch_retval = S48_UNSPECIFIC;
S48_DECLARE_GC_PROTECT(4);
S48_GC_PROTECT_4(sch_result_pid, sch_status, sch_status_list, sch_retval);
result_pid = waitpid(pid, &status, flags);
if (result_pid == -1)
s48_raise_os_error_2 (errno, s48_pid, s48_flags);
return s48_cons (s48_enter_integer (result_pid),
s48_cons (s48_enter_integer (status),
S48_NULL));
s48_raise_os_error_2 (errno, s48_pid, s48_flags);
sch_result_pid = s48_enter_integer (result_pid);
sch_status = s48_enter_integer (status);
sch_status_list = s48_cons (sch_status, S48_NULL);
sch_retval = s48_cons (sch_result_pid, sch_status_list);
S48_GC_UNPROTECT();
return sch_retval;
}