monojob.h File Reference

Single foreground job. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
int monojob_wait (const char *string)
 Wait for single foreground job to complete.

Variables

struct job_interface monojob
 Single foreground job.


Detailed Description

Single foreground job.

Definition in file monojob.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

int monojob_wait ( const char *  string  ) 

Wait for single foreground job to complete.

Parameters:
string Job description to display
Return values:
rc Job final status code

Definition at line 65 of file monojob.c.

References CTRL_C, currticks(), ECANCELED, EINPROGRESS, getchar(), iskey(), job_done(), job_kill(), monojob_rc, printf(), step(), strerror(), and TICKS_PER_SEC.

Referenced by dhcp(), imgfetch(), and pxebs().

00065                                         {
00066         int key;
00067         int rc;
00068         unsigned long last_progress_dot;
00069         unsigned long elapsed;
00070 
00071         printf ( "%s.", string );
00072         monojob_rc = -EINPROGRESS;
00073         last_progress_dot = currticks();
00074         while ( monojob_rc == -EINPROGRESS ) {
00075                 step();
00076                 if ( iskey() ) {
00077                         key = getchar();
00078                         switch ( key ) {
00079                         case CTRL_C:
00080                                 job_kill ( &monojob );
00081                                 rc = -ECANCELED;
00082                                 goto done;
00083                         default:
00084                                 break;
00085                         }
00086                 }
00087                 elapsed = ( currticks() - last_progress_dot );
00088                 if ( elapsed >= TICKS_PER_SEC ) {
00089                         printf ( "." );
00090                         last_progress_dot = currticks();
00091                 }
00092         }
00093         rc = monojob_rc;
00094 
00095 done:
00096         job_done ( &monojob, rc );
00097         if ( rc ) {
00098                 printf ( " %s\n", strerror ( rc ) );
00099         } else {
00100                 printf ( " ok\n" );
00101         }
00102         return rc;
00103 }


Variable Documentation

Single foreground job.

Definition at line 51 of file monojob.c.

Referenced by dhcp(), imgfetch(), and pxebs().


Generated on Tue Apr 6 20:01:51 2010 for gPXE by  doxygen 1.5.7.1