Index: trunk/psModules/src/detrend/Makefile.am
===================================================================
--- trunk/psModules/src/detrend/Makefile.am	(revision 10574)
+++ trunk/psModules/src/detrend/Makefile.am	(revision 10610)
@@ -11,7 +11,5 @@
 	pmBias.c \
 	pmDetrendDB.c \
-	pmShutterCorrection.c \
-	psPipe.c \
-	psIOBuffer.c
+	pmShutterCorrection.c
 
 #	pmSkySubtract.c
@@ -25,7 +23,5 @@
 	pmBias.h \
 	pmDetrendDB.h \
-	pmShutterCorrection.h \
-	psPipe.h \
-	psIOBuffer.h
+	pmShutterCorrection.h
 
 #	pmSkySubtract.h
Index: trunk/psModules/src/detrend/psIOBuffer.c
===================================================================
--- trunk/psModules/src/detrend/psIOBuffer.c	(revision 10574)
+++ 	(revision )
@@ -1,113 +1,0 @@
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <pslib.h>
-#include "psIOBuffer.h"
-
-static void psIOBufferFree (psIOBuffer *buffer)
-{
-    if (buffer == NULL)
-        return;
-
-    psFree (buffer->data);
-    return;
-}
-
-psIOBuffer *psIOBufferAlloc (int nBuffer)
-{
-
-    psIOBuffer *buffer = (psIOBuffer *)psAlloc(sizeof(psIOBuffer));
-    psMemSetDeallocator(buffer, (psFreeFunc) psIOBufferFree);
-
-    buffer->data = (char *) psAlloc (nBuffer);
-
-    buffer->nAlloc = nBuffer;
-    buffer->nReset = nBuffer;
-    buffer->nBlock = nBuffer / 2;
-    buffer->n = 0;
-    return (buffer);
-}
-
-bool psIOBufferFlush (psIOBuffer *buffer)
-{
-
-    if (buffer == NULL)
-        return false;
-    buffer->n = 0;
-    buffer->nAlloc = buffer->nReset;
-    psRealloc (buffer->data, buffer->nAlloc);
-    bzero (buffer->data, buffer->nAlloc);
-
-    return true;
-}
-
-int psIOBufferRead (psIOBuffer *buffer, int fd)
-{
-
-    int Nread, Nfree;
-
-    if (fd == 0) {
-        /* pipe is closed */
-        return (0);
-    }
-
-    Nfree = buffer->nAlloc - buffer->n;
-
-    // extend the data block if needed
-    if (Nfree < buffer->nBlock) {
-        buffer->nAlloc += 2*buffer->nBlock;
-        psRealloc (buffer->data, buffer->nAlloc);
-        Nfree = buffer->nAlloc - buffer->n;
-        bzero (buffer->data + buffer->n, Nfree);
-    }
-
-    // attempt to read from the fd into the buffer
-    Nread = read (fd, &buffer->data[buffer->n], buffer->nBlock);
-
-    if (Nread >= 0) {
-        buffer->n += Nread;
-        buffer->data[buffer->n] = 0;
-        return (Nread);
-    }
-
-    // check on exit status (try again if waiting for non-blocking fd)
-    if (Nread == -1) {
-        switch (errno) {
-        case EAGAIN:
-        case EIO:
-            /** no data available in pipe **/
-            return (-1);
-        default:
-            /** error reading from pipe **/
-            psError (PS_ERR_IO, true, "error on psIOBufferRead");
-            return (-2);
-        }
-    }
-    return (Nread);
-}
-
-/* read until buffer is empty (Nmax retries) */
-int psIOBufferReadEmpty (psIOBuffer *buffer, int Nmax, int fd)
-{
-
-    int i, status;
-
-    status = -1;
-    for (i = 0; (status != 0) && (i < Nmax); i++) {
-        status = psIOBufferRead (buffer, fd);
-        if (status == -2)
-            return false;
-        if (status == -1)
-            usleep (10000);
-        if (status > 0)
-            i = 0;
-    }
-    if (status == -1)
-        return false;
-    return true;
-}
Index: trunk/psModules/src/detrend/psIOBuffer.h
===================================================================
--- trunk/psModules/src/detrend/psIOBuffer.h	(revision 10574)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/** @file  psPipe.h
-*
-*  @brief 3-stream pipe 
-*
-*  @ingroup misc
-*
-*  @author EAM, IfA
-*
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-10 01:01:09 $
-*
-*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
-*/
-
-#ifndef PS_IO_BUFFER_H
-#define PS_IO_BUFFER_H
-
-typedef struct
-{
-    char *data;
-    int nAlloc;    // current size of allocated buffer
-    int nReset;    // size to set buffer after flush
-    int nBlock;    // number of bytes to try to read at a time
-    int n;    // current size of filled data
-}
-psIOBuffer;
-
-// psIOBuffer functions
-psIOBuffer *psIOBufferAlloc (int nBuffer);
-bool psIOBufferFlush (psIOBuffer *buffer);
-int psIOBufferRead (psIOBuffer *buffer, int fd);
-int psIOBufferReadEmpty (psIOBuffer *buffer, int maxRetries, int fd);
-
-# endif
Index: trunk/psModules/src/detrend/psPipe.c
===================================================================
--- trunk/psModules/src/detrend/psPipe.c	(revision 10574)
+++ 	(revision )
@@ -1,210 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pslib.h>
-#include <psPipe.h>
-
-void closePipes (int *stdin_fd, int *stdout_fd, int *stderr_fd)
-{
-
-    if (stdin_fd[0]  != 0)
-        close (stdin_fd[0]);
-    if (stdin_fd[1]  != 0)
-        close (stdin_fd[0]);
-    if (stdout_fd[0] != 0)
-        close (stdout_fd[0]);
-    if (stdout_fd[1] != 0)
-        close (stdout_fd[1]);
-    if (stderr_fd[0] != 0)
-        close (stderr_fd[0]);
-    if (stderr_fd[1] != 0)
-        close (stderr_fd[1]);
-}
-
-static void psPipeFree (psPipe *pipe)
-{
-    return;
-}
-
-psPipe *psPipeAlloc ()
-{
-    psPipe *pipe = (psPipe *)psAlloc(sizeof(psPipe));
-    psMemSetDeallocator(pipe, (psFreeFunc) psPipeFree);
-
-    pipe->fd_stdin  = 0;
-    pipe->fd_stdout = 0;
-    pipe->fd_stderr = 0;
-    return (pipe);
-}
-
-psPipe *psPipeOpen (char *command)
-{
-
-    int stdin_fd[2], stdout_fd[2], stderr_fd[2], status;
-    pid_t pid;
-
-    bzero (stdin_fd,  2*sizeof(int));
-    bzero (stdout_fd, 2*sizeof(int));
-    bzero (stderr_fd, 2*sizeof(int));
-
-    if (pipe (stdin_fd)  < 0) {
-        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-    if (pipe (stdout_fd) < 0) {
-        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-    if (pipe (stderr_fd) < 0) {
-        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-
-    psArray *cmd = psStringSplitArray (command, " ", false);
-    if (cmd->n <= 0) {
-        psError (PS_ERR_UNKNOWN, true, "empty command for pipe");
-        psFree (cmd);
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-
-    // create the command line array needed by execvp
-    char **argv = (char **)psAlloc((cmd->n+1)*sizeof(char *));
-    for (int i = 0; i < cmd->n; i++) {
-        argv[i] = cmd->data[i];
-    }
-    argv[cmd->n] = NULL;
-
-    pid = fork ();
-    if (!pid) { /* must be child process */
-        /* close the other ends of the pipes */
-        close (stdin_fd[1]);
-        close (stdout_fd[0]);
-        close (stderr_fd[0]);
-
-        /* tie our ends of the pipes to stdin, stdout, stderr */
-        dup2 (stdin_fd[0],  STDIN_FILENO);
-        dup2 (stdout_fd[1], STDOUT_FILENO);
-        dup2 (stderr_fd[1], STDERR_FILENO);
-
-        /* set all three unblocking */
-        setvbuf (stdin,  (char *) NULL, _IONBF, BUFSIZ);
-        setvbuf (stdout, (char *) NULL, _IONBF, BUFSIZ);
-        setvbuf (stderr, (char *) NULL, _IONBF, BUFSIZ);
-
-        status = execvp (argv[0], argv);
-
-        // this statement exits the child, not the parent, process
-        exit (1);
-    }
-    psFree (cmd);
-    psFree (argv);
-
-    if (pid == -1) {
-        psError (PS_ERR_UNKNOWN, true, "unable to create child process");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-
-    /* close the other ends of the pipes */
-    close (stdin_fd[0]);
-    stdin_fd[0]  = 0;
-    close (stdout_fd[1]);
-    stdout_fd[1] = 0;
-    close (stderr_fd[1]);
-    stderr_fd[1] = 0;
-
-    /* make the pipes non-blocking */
-    fcntl (stdin_fd[1],  F_SETFL, O_NONBLOCK);
-    fcntl (stdout_fd[0], F_SETFL, O_NONBLOCK);
-    fcntl (stderr_fd[0], F_SETFL, O_NONBLOCK);
-
-    psPipe *pipe = psPipeAlloc();
-
-    pipe->pid    = pid;
-    pipe->fd_stdin  = stdin_fd[1];
-    pipe->fd_stdout = stdout_fd[0];
-    pipe->fd_stderr = stderr_fd[0];
-
-    return (pipe);
-}
-
-// this function returns the exit status of the called function
-// or a value > 255 on an error
-int psPipeClose (psPipe *pipe)
-{
-    int close_status;
-    int exit_status;
-    int wait_status;
-    int result;
-
-    PS_ASSERT_PTR_NON_NULL(pipe, false);
-
-    close_status = true;
-    if (close (pipe->fd_stdin) != 0) {
-        psError(PS_ERR_IO, true, "error closing the pipe stdin (pid %d, error %s)\n", pipe->pid, strerror(errno));
-        close_status = false;
-    }
-    if (close (pipe->fd_stdout) != 0) {
-        psError(PS_ERR_IO, true, "error closing the pipe stdout (pid %d, error %s)\n", pipe->pid, strerror(errno));
-        close_status = false;
-    }
-    if (close (pipe->fd_stderr) != 0) {
-        psError(PS_ERR_IO, true, "error closing the pipe sterr (pid %d, error %s)\n", pipe->pid, strerror(errno));
-        close_status = false;
-    }
-
-    // we expect the child process to have exited.
-    // wait for the exit condition, but no longer than 100ms
-    for (int i = 0; i < 10; i++) {
-        result = waitpid (pipe->pid, &wait_status, WNOHANG);
-        switch (result) {
-        case -1:   // error on waitpid
-            switch (errno) {
-            case ECHILD:
-                psError(PS_ERR_IO, true, "unknown PID, not a child process: %d\n", pipe->pid);
-                return 0x100;
-            default:
-                psAbort ("psPipeClose", "unexpected response to waitpid: %d\n", result);
-            }
-            break;
-
-        case 0:   // child not yet exited
-            usleep (10000);
-            continue;
-
-        default:
-            if (result != pipe->pid) {
-                psAbort ("psPipeClose", "waitpid error: mis-matched PID (%d vs %d).  programming error\n", result, pipe->pid);
-            }
-            if (WIFEXITED(wait_status)) {
-                exit_status = WEXITSTATUS(wait_status);
-                if (close_status) {
-                    return exit_status;
-                } else {
-                    return (0x100);
-                }
-            }
-            if (WIFSIGNALED(wait_status)) {
-                psError(PS_ERR_IO, true, "job %d exited on signal %d\n", pipe->pid, WTERMSIG(wait_status));
-                return (0x100 + WTERMSIG(wait_status));
-            }
-            if (WIFSTOPPED(wait_status)) {
-                psAbort ("psPipeClose", "waitpid returns 'stopped' programming error\n");
-            }
-        }
-    }
-    psError(PS_ERR_IO, true, "child process pid %d did not exit\n", pipe->pid);
-    return 0x100;
-}
Index: trunk/psModules/src/detrend/psPipe.h
===================================================================
--- trunk/psModules/src/detrend/psPipe.h	(revision 10574)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/** @file  psPipe.h
-*
-*  @brief 3-stream pipe 
-*
-*  @ingroup misc
-*
-*  @author EAM, IfA
-*
-*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-11-20 17:50:17 $
-*
-*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
-*/
-
-#ifndef PS_PIPE_H
-#define PS_PIPE_H
-
-// move these to pslib??
-typedef struct
-{
-    int pid;
-    int fd_stdin;
-    int fd_stdout;
-    int fd_stderr;
-}
-psPipe;
-
-// psPipe functions
-psPipe *psPipeAlloc ();
-psPipe *psPipeOpen (char *command);
-int     psPipeClose (psPipe *pipe);
-
-# endif
