Mercurial > hg > nnchat
changeset 233:6b1c67274f6c
Use a pipe to redirect executed browser's stderr and stdout when opening profiles.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 13 Mar 2011 11:21:41 +0200 |
parents | 3140ea43d4a3 |
children | cbb9db83ef18 |
files | nnchat.c |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/nnchat.c Sun Mar 13 11:21:16 2011 +0200 +++ b/nnchat.c Sun Mar 13 11:21:41 2011 +0200 @@ -718,13 +718,22 @@ #else { int status; + int fds[2]; pid_t pid; snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr); th_free(tmpStr); + if (pipe(fds) == -1) { + int ret = errno; + printMsg("Could not open process communication pipe! (%d, %s)\n", ret, strerror(ret)); + return 0; + } + if ((pid = fork()) < 0) { printMsg("Could not create sub-process!\n"); } else if (pid == 0) { + dup2(fds[1], STDOUT_FILENO); + dup2(fds[0], STDERR_FILENO); execlp(setBrowser, setBrowser, "-remote", tmpBuf, (void *)NULL); _exit(errno); }