raster pushed a commit to branch master.
commit 3a2a58473bacfe40d11423fa349139f51cb831d7
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date: Fri Aug 30 12:14:18 2013 +0900
ad erro handling for pty alloc (never seen it fail!)
---
src/bin/termio.c | 6 ++++++
src/bin/termpty.c | 41 +++++++++++++++++++++++++++++++++++------
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 329aa1c..97867c0 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -4161,6 +4161,12 @@ termio_add(Evas_Object *parent, Config *config, const
char *cmd, Eina_Bool login
#endif
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback);
+ if (!sd->pty)
+ {
+ ERR("Cannot allocate termpty");
+ evas_object_del(obj);
+ return NULL;
+ }
sd->pty->obj = obj;
sd->pty->cb.change.func = _smart_pty_change;
sd->pty->cb.change.data = obj;
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index ab1f548..d5c5e2b 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -283,23 +283,52 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const
char *cd, int w, int h
ty->swap = ty->state;
ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h);
- if (!ty->screen) goto err;
+ if (!ty->screen)
+ {
+ ERR("Allocation of term screen %ix%i", ty->wm ty->h);
+ goto err;
+ }
ty->screen2 = calloc(1, sizeof(Termcell) * ty->w * ty->h);
- if (!ty->screen2) goto err;
+ if (!ty->screen2)
+ {
+ ERR("Allocation of term screen2 %ix%i", ty->wm ty->h);
+ goto err;
+ }
ty->circular_offset = 0;
ty->fd = posix_openpt(O_RDWR | O_NOCTTY);
- if (ty->fd < 0) goto err;
- if (grantpt(ty->fd) != 0) goto err;
- if (unlockpt(ty->fd) != 0) goto err;
+ if (ty->fd < 0)
+ {
+ ERR("posix_openpt failed: %s", strerror(errno));
+ goto err;
+ }
+ if (grantpt(ty->fd) != 0)
+ {
+ ERR("grantpt failed: %s", strerror(errno));
+ goto err;
+ }
+ if (unlockpt(ty->fd) != 0)
+ {
+ ERR("unlockpt failed: %s", strerror(errno));
+ goto err;
+ }
pty = ptsname(ty->fd);
ty->slavefd = open(pty, O_RDWR | O_NOCTTY);
- if (ty->slavefd < 0) goto err;
+ if (ty->slavefd < 0)
+ {
+ ERR("open of pty '%s' failed: %s", pty, strerror(errno));
+ goto err;
+ }
fcntl(ty->fd, F_SETFL, O_NDELAY);
ty->hand_exe_exit = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
_cb_exe_exit, ty);
+ if (!ty->hand_exe_exit)
+ {
+ ERR("event handler add failed");
+ goto err;
+ }
ty->pid = fork();
if (!ty->pid)
{
--
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk