fix exit code handling and propagate exit from pty->io->main

SVN revision: 72545
This commit is contained in:
Carsten Haitzler 2012-06-20 14:12:26 +00:00
parent 596357c77a
commit 26a88cd2dd
4 changed files with 19 additions and 3 deletions

View File

@ -70,6 +70,12 @@ _cb_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNU
else ecore_timer_delay(flush_timer, 0.25);
}
static void
_cb_exited(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
elm_exit();
}
void
main_trans_update(const Config *config)
{
@ -281,6 +287,7 @@ elm_main(int argc, char **argv)
edje_object_part_swallow(bg, "terminology.content", o);
evas_object_smart_callback_add(o, "options", _cb_options, NULL);
evas_object_smart_callback_add(o, "change", _cb_change, NULL);
evas_object_smart_callback_add(o, "exited", _cb_exited, NULL);
evas_object_show(o);
main_trans_update(config);

View File

@ -1130,6 +1130,12 @@ _smart_pty_cancel_sel(void *data)
}
}
static void
_smart_pty_exited(void *data)
{
evas_object_smart_callback_call(data, "exited", NULL);
}
Evas_Object *
termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h)
{
@ -1161,6 +1167,8 @@ termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h)
sd->pty->cb.set_icon.data = obj;
sd->pty->cb.cancel_sel.func = _smart_pty_cancel_sel;
sd->pty->cb.cancel_sel.data = obj;
sd->pty->cb.exited.func = _smart_pty_exited;
sd->pty->cb.exited.data = obj;
_smart_size(obj, w, h, EINA_FALSE);
return obj;
}

View File

@ -1488,8 +1488,8 @@ _cb_exe_exit(void *data, int type __UNUSED__, void *event)
Termpty *ty = data;
if (ev->pid != ty->pid) return ECORE_CALLBACK_PASS_ON;
// XXX: report via cb
exit(ev->exit_code);
ty->exit_code = ev->exit_code;
if (ty->cb.exited.func) ty->cb.exited.func(ty->cb.exited.data);
return ECORE_CALLBACK_PASS_ON;
}

View File

@ -68,7 +68,7 @@ struct _Termpty
struct {
void (*func) (void *data);
void *data;
} change, scroll, set_title, set_icon, cancel_sel;
} change, scroll, set_title, set_icon, cancel_sel, exited;
} cb;
struct {
const char *title;
@ -84,6 +84,7 @@ struct _Termpty
int *buf;
int buflen;
Termstate state, save, swap;
int exit_code;
unsigned int altbuf : 1;
};