diff --git a/src/common/remoteio.h b/src/common/execio.h copy from src/common/remoteio.h copy to src/common/execio.h --- a/src/common/remoteio.h +++ b/src/common/execio.h @@ -17,16 +17,23 @@ along with DistRen. If not, see . */ -#ifndef _DISTREN_REMOTEIO_H -#define _DISTREN_REMOTEIO_H +#ifndef _DISTREN_EXECIO_H +#define _DISTREN_EXECIO_H /* - This file tries to abstract away getting a socket/fd that talks to a remote service + This file tries to abstract away getting a socket/fd that talks to a spawned program */ #include -struct remoteio +enum execio_state + { + EXECIO_STATE_ERROR, + EXECIO_STATE_EOF + }; + + +struct execio { int pipe_write; int pipe_read; @@ -35,14 +42,19 @@ struct remoteio }; /* nonzsero return on error */ -int remoteio_open(const char *spec, struct remoteio **rem); +int execio_open(const char *spec, struct execio **eio); -/* blocks, returns 0 if len is 0 or on error */ -size_t remoteio_read(struct remoteio *rem, void *buf, size_t len); -size_t remoteio_write(struct remoteio *rem, void *buf, size_t len); +/* + blocks, + returns 0 if len is 0. Otherwise, only returns 0 on error/EOF: use execio_state() to determine +*/ +size_t execio_read(struct execio *eio, void *buf, size_t len); +size_t execio_write(struct execio *eio, void *buf, size_t len); + +enum execio_state execio_state(struct execio *eio); /* nonzero return on error */ -int remoteio_close(struct remoteio *rem); +int execio_close(struct execio *eio); #endif