/* * ep - extended pipelining * * proctable.h - process table header file * ____________________________________________________________ * * Developed by Ondrej Jombik * and Lubomir Host * Copyright (c) 2000-2003 Platon SDG, http://platon.sk/ * All rights reserved. * * See README file for more information about this software. * See COPYING file for license information. * * Download the latest version from * http://platon.sk/projects/ep/ */ /* $Platon: ep/src/proctable.h,v 1.16 2003/05/03 09:58:19 nepto Exp $ */ #ifndef _PROCTABLE_H #define _PROCTABLE_H #include "process.h" /* We need fd_set. */ #include #define BUFSIZE 150U #define proctable_free(p_ptbl) proctable_destroy(p_ptbl) typedef struct process** PROCTABLE; /* Get size of valid process table. */ int proctable_get_size(PROCTABLE ptbl); /* Create process table with appropriate size. */ PROCTABLE proctable_create(const int size); /* Destroy proctable. */ void proctable_destroy(PROCTABLE *p_ptbl); /* Join two proctables. Appends src_ptbl to p_dest_ptbl. */ /* Returns 0 on error, -1 on success. */ int proctable_join(PROCTABLE *p_dest_ptbl, PROCTABLE src_ptbl); /* Get index of process in process table by pid. */ int proctable_get_process_index_by_pid(PROCTABLE ptbl, int pid); /* Get index of process in process table by its name. */ /* Returns -1 when not found, index on sucess. */ int proctable_get_process_index_by_name(PROCTABLE ptbl, char *name); /* Add standart process with streams stdin, stdout, stderr to proc. */ /* Index it as ptbl[0] and move all ptbl[x] to ptbl[x+1]. */ /* Returns -1 on error, 0 on success. */ int proctable_add_std_process(PROCTABLE *p_ptbl); /* Update processes. */ int proctable_update(PROCTABLE ptbl); /* Creates the pipes in process table. */ int proctable_create_pipes(PROCTABLE ptbl); /* Fork processes and dup pipes. Exec the processes. */ int proctable_exec(PROCTABLE ptbl); /* Closing 2nd sides of pipes. */ void proctable_close_2nd_sides_of_pipes(PROCTABLE ptbl); /* Remove process from process table, when exited. */ int proctable_remove_process(PROCTABLE *p_ptbl, const int proc_id); /* Remove all specified process and fd links with appropriate equivalents. */ int proctable_remove_process_fd_links(PROCTABLE ptbl, int proc_id, int fd_id); /* Prints the whole processes hierarchy to stdout. */ void proctable_print(PROCTABLE ptbl); /* Function read on opened filedescriptors and write */ /* to 2nd sides pipes. */ int proctable_read( PROCTABLE *p_ptbl, fd_set *p_rfds, fd_set *p_wfds, fd_set *p_efds); /* Check if processes are still running. */ int proctable_wait(PROCTABLE *p_ptbl); /* Same as above, but only processes with closed fds. */ int proctable_wait2(PROCTABLE *p_ptbl); #endif /* #ifndef _PROCTABLE_H */