1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-05-09 02:36:12 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "s.h"
|
|
|
|
|
|
|
|
int signalled;
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
void sigio_handler(int arg)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
signalled = 1;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
int main(void)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
#if defined(SIGIO) && defined(FASYNC) && defined(F_SETFL) && defined(F_SETOWN)
|
|
|
|
int p[2];
|
|
|
|
int ret;
|
|
|
|
#define OUT 0
|
|
|
|
#define IN 1
|
|
|
|
if (pipe(p) == -1) return 1;
|
|
|
|
signalled = 0;
|
|
|
|
signal(SIGIO, sigio_handler);
|
|
|
|
ret = fcntl(p[OUT], F_GETFL, 0);
|
|
|
|
fcntl(p[OUT], F_SETFL, ret | FASYNC);
|
|
|
|
fcntl(p[OUT], F_SETOWN, getpid());
|
|
|
|
switch(fork()) {
|
|
|
|
case -1:
|
|
|
|
return 1;
|
|
|
|
case 0:
|
|
|
|
close(p[OUT]);
|
|
|
|
write(p[IN], "x", 1);
|
|
|
|
sleep(1);
|
|
|
|
exit(0);
|
|
|
|
default:
|
|
|
|
close(p[IN]);
|
|
|
|
while(wait(NULL) == -1 && errno == EINTR) /*nothing*/;
|
|
|
|
}
|
|
|
|
if (signalled) return 0; else return 1;
|
|
|
|
#else
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|