View of xos/tests/job_control3.c


XOS | Parent Directory | View | Download

/* Copyright (C) 2008  Emmanuel Varoquaux
 
   This file is part of XOS.
 
   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 3 of the License, or
   (at your option) any later version.
 
   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.
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
/* A lancer avec ./test. Attendre 1 seconde (le shell reprend la main), puis
 * saisir 1 caractere, sans '\n'. Ce caractere est affiché ! */
 
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
 
static void die()
{
  perror(0);
  exit(1);
}
 
int main()
{
  char buf[100];
 
  if (!fork()) {
    if (read(0, buf, 100) < 0)
      die();
    printf("Lu: %s\n", buf);
  }
  sleep(1);
 
 
  return 0;
}