=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/client.c,v retrieving revision 1.9 retrieving revision 1.10 diff -c -r1.9 -r1.10 *** src/usr.bin/tmux/client.c 2009/07/30 16:32:12 1.9 --- src/usr.bin/tmux/client.c 2009/08/08 21:18:23 1.10 *************** *** 1,4 **** ! /* $OpenBSD: client.c,v 1.9 2009/07/30 16:32:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: client.c,v 1.10 2009/08/08 21:18:23 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 43,49 **** struct msg_identify_data data; struct winsize ws; size_t size; ! int mode; char *name, *term; char rpathbuf[MAXPATHLEN]; --- 43,49 ---- struct msg_identify_data data; struct winsize ws; size_t size; ! int fd, mode; char *name, *term; char rpathbuf[MAXPATHLEN]; *************** *** 53,59 **** if (lstat(path, &sb) != 0) { if (cmdflags & CMD_STARTSERVER && errno == ENOENT) { ! if ((cctx->srv_fd = server_start(path)) == -1) goto start_failed; goto server_started; } --- 53,59 ---- if (lstat(path, &sb) != 0) { if (cmdflags & CMD_STARTSERVER && errno == ENOENT) { ! if ((fd = server_start(path)) == -1) goto start_failed; goto server_started; } *************** *** 72,86 **** goto not_found; } ! if ((cctx->srv_fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) fatal("socket"); ! if (connect( ! cctx->srv_fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { if (errno == ECONNREFUSED) { if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER)) goto not_found; ! if ((cctx->srv_fd = server_start(path)) == -1) goto start_failed; goto server_started; } --- 72,85 ---- goto not_found; } ! if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) fatal("socket"); ! if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { if (errno == ECONNREFUSED) { if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER)) goto not_found; ! if ((fd = server_start(path)) == -1) goto start_failed; goto server_started; } *************** *** 88,97 **** } server_started: ! if ((mode = fcntl(cctx->srv_fd, F_GETFL)) == -1) fatal("fcntl failed"); ! if (fcntl(cctx->srv_fd, F_SETFL, mode|O_NONBLOCK) == -1) fatal("fcntl failed"); cctx->srv_in = buffer_create(BUFSIZ); cctx->srv_out = buffer_create(BUFSIZ); --- 87,97 ---- } server_started: ! if ((mode = fcntl(fd, F_GETFL)) == -1) fatal("fcntl failed"); ! if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1) fatal("fcntl failed"); + cctx->srv_fd = fd; cctx->srv_in = buffer_create(BUFSIZ); cctx->srv_out = buffer_create(BUFSIZ);