summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-08-30 12:14:18 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-08-30 12:14:18 +0900
commit3a2a58473bacfe40d11423fa349139f51cb831d7 (patch)
tree2d454586fe8ac43d87230f1b19323183765ecd18
parent2dac064d3bf2e07193320df7ba36d85bb929553a (diff)
ad erro handling for pty alloc (never seen it fail!)
-rw-r--r--src/bin/termio.c6
-rw-r--r--src/bin/termpty.c41
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
4161#endif 4161#endif
4162 4162
4163 sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback); 4163 sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback);
4164 if (!sd->pty)
4165 {
4166 ERR("Cannot allocate termpty");
4167 evas_object_del(obj);
4168 return NULL;
4169 }
4164 sd->pty->obj = obj; 4170 sd->pty->obj = obj;
4165 sd->pty->cb.change.func = _smart_pty_change; 4171 sd->pty->cb.change.func = _smart_pty_change;
4166 sd->pty->cb.change.data = obj; 4172 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
283 ty->swap = ty->state; 283 ty->swap = ty->state;
284 284
285 ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h); 285 ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h);
286 if (!ty->screen) goto err; 286 if (!ty->screen)
287 {
288 ERR("Allocation of term screen %ix%i", ty->wm ty->h);
289 goto err;
290 }
287 ty->screen2 = calloc(1, sizeof(Termcell) * ty->w * ty->h); 291 ty->screen2 = calloc(1, sizeof(Termcell) * ty->w * ty->h);
288 if (!ty->screen2) goto err; 292 if (!ty->screen2)
293 {
294 ERR("Allocation of term screen2 %ix%i", ty->wm ty->h);
295 goto err;
296 }
289 297
290 ty->circular_offset = 0; 298 ty->circular_offset = 0;
291 299
292 ty->fd = posix_openpt(O_RDWR | O_NOCTTY); 300 ty->fd = posix_openpt(O_RDWR | O_NOCTTY);
293 if (ty->fd < 0) goto err; 301 if (ty->fd < 0)
294 if (grantpt(ty->fd) != 0) goto err; 302 {
295 if (unlockpt(ty->fd) != 0) goto err; 303 ERR("posix_openpt failed: %s", strerror(errno));
304 goto err;
305 }
306 if (grantpt(ty->fd) != 0)
307 {
308 ERR("grantpt failed: %s", strerror(errno));
309 goto err;
310 }
311 if (unlockpt(ty->fd) != 0)
312 {
313 ERR("unlockpt failed: %s", strerror(errno));
314 goto err;
315 }
296 pty = ptsname(ty->fd); 316 pty = ptsname(ty->fd);
297 ty->slavefd = open(pty, O_RDWR | O_NOCTTY); 317 ty->slavefd = open(pty, O_RDWR | O_NOCTTY);
298 if (ty->slavefd < 0) goto err; 318 if (ty->slavefd < 0)
319 {
320 ERR("open of pty '%s' failed: %s", pty, strerror(errno));
321 goto err;
322 }
299 fcntl(ty->fd, F_SETFL, O_NDELAY); 323 fcntl(ty->fd, F_SETFL, O_NDELAY);
300 324
301 ty->hand_exe_exit = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, 325 ty->hand_exe_exit = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
302 _cb_exe_exit, ty); 326 _cb_exe_exit, ty);
327 if (!ty->hand_exe_exit)
328 {
329 ERR("event handler add failed");
330 goto err;
331 }
303 ty->pid = fork(); 332 ty->pid = fork();
304 if (!ty->pid) 333 if (!ty->pid)
305 { 334 {