Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <string.h>
  19. #include <stdio.h>
  20. #include <errno.h>
  21. #include <gpxe/process.h>
  22. #include <console.h>
  23. #include <gpxe/keys.h>
  24. #include <gpxe/job.h>
  25. #include <gpxe/monojob.h>
  26. /** @file
  27. *
  28. * Single foreground job
  29. *
  30. */
  31. static int monojob_rc;
  32. static void monojob_done ( struct job_interface *job __unused, int rc ) {
  33. monojob_rc = rc;
  34. }
  35. /** Single foreground job operations */
  36. static struct job_interface_operations monojob_operations = {
  37. .done = monojob_done,
  38. .kill = ignore_job_kill,
  39. .progress = ignore_job_progress,
  40. };
  41. /** Single foreground job */
  42. struct job_interface monojob = {
  43. .intf = {
  44. .dest = &null_job.intf,
  45. .refcnt = NULL,
  46. },
  47. .op = &monojob_operations,
  48. };
  49. /**
  50. * Wait for single foreground job to complete
  51. *
  52. * @v string Job description to display
  53. * @ret rc Job final status code
  54. */
  55. int monojob_wait ( const char *string ) {
  56. int key;
  57. int rc;
  58. printf ( "%s... ", string );
  59. monojob_rc = -EINPROGRESS;
  60. while ( monojob_rc == -EINPROGRESS ) {
  61. step();
  62. if ( iskey() ) {
  63. key = getchar();
  64. switch ( key ) {
  65. case CTRL_C:
  66. job_kill ( &monojob );
  67. rc = -ECANCELED;
  68. goto done;
  69. default:
  70. break;
  71. }
  72. }
  73. }
  74. rc = monojob_rc;
  75. done:
  76. if ( rc ) {
  77. printf ( "%s\n", strerror ( rc ) );
  78. } else {
  79. printf ( "ok\n" );
  80. }
  81. return rc;
  82. }