summaryrefslogtreecommitdiffstats
path: root/src/core/monojob.c
diff options
context:
space:
mode:
authorMichael Brown2008-06-12 22:47:19 +0200
committerMichael Brown2010-06-22 15:40:09 +0200
commita03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc (patch)
treeb02a2bf151bfd212bea20ae7ac208c64157a0895 /src/core/monojob.c
parent[interface] Expand object interface to allow for polymorphic interfaces (diff)
downloadipxe-a03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc.tar.gz
ipxe-a03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc.tar.xz
ipxe-a03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc.zip
[interface] Convert all job-control interfaces to generic interfaces
Remove job-control as an interface type, and replace job-control interfaces with generic interfaces supporting the close() method. (Both done() and kill() are absorbed into the function of close(); kill() is merely close(-ECANCELED).) Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/monojob.c')
-rw-r--r--src/core/monojob.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/core/monojob.c b/src/core/monojob.c
index cd255076..994edeb1 100644
--- a/src/core/monojob.c
+++ b/src/core/monojob.c
@@ -36,25 +36,19 @@ FILE_LICENCE ( GPL2_OR_LATER );
static int monojob_rc;
-static void monojob_done ( struct job_interface *job __unused, int rc ) {
+static void monojob_close ( struct interface *intf, int rc ) {
monojob_rc = rc;
+ intf_restart ( intf, rc );
}
-/** Single foreground job operations */
-static struct job_interface_operations monojob_operations = {
- .done = monojob_done,
- .kill = ignore_job_kill,
- .progress = ignore_job_progress,
+static struct interface_operation monojob_intf_op[] = {
+ INTF_OP ( intf_close, struct interface *, monojob_close ),
};
-/** Single foreground job */
-struct job_interface monojob = {
- .intf = {
- .dest = &null_job.intf,
- .refcnt = NULL,
- },
- .op = &monojob_operations,
-};
+static struct interface_descriptor monojob_intf_desc =
+ INTF_DESC_PURE ( monojob_intf_op );
+
+struct interface monojob = INTF_INIT ( monojob_intf_desc );
/**
* Wait for single foreground job to complete
@@ -77,9 +71,8 @@ int monojob_wait ( const char *string ) {
key = getchar();
switch ( key ) {
case CTRL_C:
- job_kill ( &monojob );
- rc = -ECANCELED;
- goto done;
+ monojob_close ( &monojob, -ECANCELED );
+ break;
default:
break;
}
@@ -92,8 +85,6 @@ int monojob_wait ( const char *string ) {
}
rc = monojob_rc;
-done:
- job_done ( &monojob, rc );
if ( rc ) {
printf ( " %s\n", strerror ( rc ) );
} else {