/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.exec;

import lc.mecha.lang.Handle;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;

/**
 * Classes implementing this interface provide future results for a process execution and access to the stdin
 * stream for the executed process (whether local or remote).
 *
 * @author Alex Leigh
 */
public interface ProcessExecution extends Handle, AutoCloseable {
    /**
     * Return an <code>InputStream</code> which corresponds to <code>stdout</code> on the process.
     *
     * @return
     * @throws IOException
     */
    InputStream getInputStream() throws IOException;

    /**
     * Return an <code>OutputStream</code> which corresponds to <code>stdin</code> on the process.
     *
     * @return
     * @throws IOException
     */
    OutputStream getOutputStream() throws IOException;

    /**
     * Return an <code>InputStream</code> which corresponds to <code>stderr</code> on the process.
     *
     * @return
     * @throws IOException
     */
    InputStream getErrorStream() throws IOException;

    String drainInput(Charset set) throws IOException;

    String drainInput() throws IOException;

    int getReturnCode();
}
