summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/winwait.c
blob: ebba52ff4b70421c53c95862be4b2e1d739b092c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/***********************************************************************/
/*                                                                     */
/*                           Objective Caml                            */
/*                                                                     */
/*              Pascal Cuoq, projet Cristal, INRIA Rocquencourt        */
/*                                                                     */
/*  Copyright 1996 Institut National de Recherche en Informatique et   */
/*  Automatique.  Distributed only by permission.                      */
/*                                                                     */
/***********************************************************************/

/* $Id$ */

#include <windows.h>
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
#include <process.h>
#include "unixsupport.h"
#include <sys/types.h>

static value alloc_process_status(pid, status)
     int pid, status;
{
  value st, res;
  Push_roots(r, 1);

  
  st = alloc(1, 0);
  Field(st, 0) = Val_int(status);
 
  r[0] = st;
  res = alloc_tuple(2);
  Field(res, 0) = Val_int(pid);
  Field(res, 1) = r[0];
  Pop_roots();
  return res;
}

value win_waitpid(flags, vpid_req) /* ML */
     value flags, vpid_req;
{
  int status, pid_req;
  pid_req = Int_val(vpid_req);
  if (_cwait(&status, pid_req, 0/* ignored by win32 */) == -1)
	uerror("waitpid", Nothing);  
  return alloc_process_status(pid_req, status);
}