diff options
author | ferrieux <ferrieux@users.sourceforge.net> | 2008-07-21 21:02:11 (GMT) |
---|---|---|
committer | ferrieux <ferrieux@users.sourceforge.net> | 2008-07-21 21:02:11 (GMT) |
commit | 4ca6151924c3e7338fb1cdca30d81430477673f8 (patch) | |
tree | 5a49a31553d209c8b45882a0b0716544c8bf918e /unix/tclUnixPipe.c | |
parent | 24289b9502c809549472c1edc7398415f51f578e (diff) | |
download | tcl-4ca6151924c3e7338fb1cdca30d81430477673f8.zip tcl-4ca6151924c3e7338fb1cdca30d81430477673f8.tar.gz tcl-4ca6151924c3e7338fb1cdca30d81430477673f8.tar.bz2 |
TIP #304 implementation
Diffstat (limited to 'unix/tclUnixPipe.c')
-rw-r--r-- | unix/tclUnixPipe.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 64b58a1..6d4ac4e 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPipe.c,v 1.42 2008/03/14 16:32:52 rmax Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.43 2008/07/21 21:02:20 ferrieux Exp $ */ #include "tclInt.h" @@ -769,6 +769,50 @@ TclpCreateCommandChannel( /* *---------------------------------------------------------------------- * + * Tcl_CreatePipe -- + * + * System dependent interface to create a pipe for the [chan pipe] + * command. Stolen from TclX. + * + * Parameters: + * o interp - Errors returned in result. + * o rchan, wchan - Returned read and write side. + * o flags - Reserved for future use. + * Results: + * TCL_OK or TCL_ERROR. + * + *---------------------------------------------------------------------- + */ +int +Tcl_CreatePipe ( + Tcl_Interp *interp, + Tcl_Channel *rchan, + Tcl_Channel *wchan, + int flags + ) +{ + int fileNums [2]; + + if (pipe (fileNums) < 0) { + Tcl_AppendResult (interp, "pipe creation failed: ", + Tcl_PosixError (interp), (char *) NULL); + return TCL_ERROR; + } + *rchan = Tcl_MakeFileChannel ((ClientData) fileNums [0], + TCL_READABLE); + Tcl_RegisterChannel (interp, *rchan); + + *wchan = Tcl_MakeFileChannel ((ClientData) fileNums [1], + TCL_WRITABLE); + Tcl_RegisterChannel (interp, *wchan); + + return TCL_OK; +} + + +/* + *---------------------------------------------------------------------- + * * TclGetAndDetachPids -- * * This function is invoked in the generic implementation of a |