PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/testsuite/expect/test16.4.prog.c

https://github.com/cfenoy/slurm
C | 54 lines | 23 code | 4 blank | 27 comment | 5 complexity | 559bea239cffd28ecbf5b4029d7f3a91 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0
  1. /*****************************************************************************\
  2. * test1.18.proc.c - Simple I/O test program for SLURM regression test1.18.
  3. * Print "waiting\n" to stdout and wait for "exit" as stdin.
  4. *****************************************************************************
  5. * Copyright (C) 2002 The Regents of the University of California.
  6. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  7. * Written by Morris Jette <jette1@llnl.gov>
  8. * CODE-OCEC-09-009. All rights reserved.
  9. *
  10. * This file is part of SLURM, a resource management program.
  11. * For details, see <http://www.schedmd.com/slurmdocs/>.
  12. * Please also read the included file: DISCLAIMER.
  13. *
  14. * SLURM is free software; you can redistribute it and/or modify it under
  15. * the terms of the GNU General Public License as published by the Free
  16. * Software Foundation; either version 2 of the License, or (at your option)
  17. * any later version.
  18. *
  19. * SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
  20. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  21. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  22. * details.
  23. *
  24. * You should have received a copy of the GNU General Public License along
  25. * with SLURM; if not, write to the Free Software Foundation, Inc.,
  26. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  27. \*****************************************************************************/
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <unistd.h>
  32. main (int argc, char **argv)
  33. {
  34. char in_line[10];
  35. int i;
  36. fprintf(stdout, "WAITING\n");
  37. fflush(stdout);
  38. for (i=0; i<sizeof(in_line); ) {
  39. in_line[i] = getc(stdin);
  40. if ((in_line[i] < 'a') ||
  41. (in_line[i] > 'z'))
  42. i = 0;
  43. else if (strncmp(in_line, "exit", 4) == 0)
  44. exit(0);
  45. else
  46. i++;
  47. }
  48. fprintf(stderr, "Invalid input\n");
  49. exit(1);
  50. }