| version 1.9, 2001/12/20 00:26:52 |
version 1.10, 2002/02/05 22:37:03 |
|
|
| /* |
/* |
| * $Log$ |
* $Id$ |
| * Revision 1.9 2001/12/20 00:26:52 jombik9 |
*/ |
| * Various Makefile & code improvements. |
|
| * wait() implementation - no error is reported on ctrl+d now |
|
| * |
|
| * Revision 1.8 2001/12/13 17:33:40 jombik9 |
|
| * Steps to fix stream bug. |
|
| * |
|
| * Revision 1.7 2001/12/13 11:22:01 jombik9 |
|
| * fcntl() added |
|
| * |
|
| * Revision 1.6 2001/12/04 21:16:21 jombik9 |
|
| * Some changes -- try to make support for stream oriented applications. |
|
| * |
|
| * Revision 1.5 2001/12/04 17:17:52 jombik9 |
|
| * n_link sychronizations |
|
| * |
|
| * Revision 1.4 2001/12/02 23:30:07 jombik9 |
|
| * A lot of new functions added. |
|
| * Various improvements. |
|
| * |
|
| * Revision 1.3 2001/09/21 19:54:45 host8 |
|
| * Cosmetics changes in *.c |
|
| * |
|
| * Revision 1.2 2001/09/21 19:44:51 host8 |
|
| * Added $Log$ |
|
| * Added Revision 1.9 2001/12/20 00:26:52 jombik9 |
|
| * Added Various Makefile & code improvements. |
|
| * Added wait() implementation - no error is reported on ctrl+d now |
|
| * Added |
|
| * Added Revision 1.8 2001/12/13 17:33:40 jombik9 |
|
| * Added Steps to fix stream bug. |
|
| * Added |
|
| * Added Revision 1.7 2001/12/13 11:22:01 jombik9 |
|
| * Added fcntl() added |
|
| * Added |
|
| * Added Revision 1.6 2001/12/04 21:16:21 jombik9 |
|
| * Added Some changes -- try to make support for stream oriented applications. |
|
| * Added |
|
| * Added Revision 1.5 2001/12/04 17:17:52 jombik9 |
|
| * Added n_link sychronizations |
|
| * Added |
|
| * Added Revision 1.4 2001/12/02 23:30:07 jombik9 |
|
| * Added A lot of new functions added. |
|
| * Added Various improvements. |
|
| * Added |
|
| * Added Revision 1.3 2001/09/21 19:54:45 host8 |
|
| * Added Cosmetics changes in *.c |
|
| * Added keyword substitution |
|
| * |
|
| */ |
|
| #ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
| # include "config.h" |
# include "config.h" |
| #endif |
#endif |
|
|
| #endif |
#endif |
| |
|
| #include <fcntl.h> |
#include <fcntl.h> |
| |
#include <sys/stat.h> /* S_IFCHR */ |
| |
|
| #include <cfg/str/strdyn.h> |
#include <cfg/str/strdyn.h> |
| |
|
| Line 441 proctable_exec(ptbl) |
|
| Line 393 proctable_exec(ptbl) |
|
| dup(ptbl[i]->fd[k].pipe[k ? 1 : 0]); |
dup(ptbl[i]->fd[k].pipe[k ? 1 : 0]); |
| #else |
#else |
| dup2(ptbl[i]->fd[k].pipe[k ? 1 : 0], k); |
dup2(ptbl[i]->fd[k].pipe[k ? 1 : 0], k); |
| |
|
| #endif |
#endif |
| /* See the '1 ||' below. |
/* See the '1 ||' below. |
| close(ptbl[i]->fd[k].pipe[0]); |
close(ptbl[i]->fd[k].pipe[0]); |
| close(ptbl[i]->fd[k].pipe[1]); |
close(ptbl[i]->fd[k].pipe[1]); |
| */ |
*/ |
| } |
} |
| else { |
else { |
| #if DEBUG |
#if DEBUG |
| Line 465 proctable_exec(ptbl) |
|
| Line 418 proctable_exec(ptbl) |
|
| for (k = 0; k < N_FD; k++) |
for (k = 0; k < N_FD; k++) |
| if (ptbl[i]->fd[k].n_link == 0) |
if (ptbl[i]->fd[k].n_link == 0) |
| close(k); |
close(k); |
| */ |
*/ |
| /* setvbuf(stdout, NULL, _IONBF, 0); */ |
/* setvbuf(stdout, NULL, _IONBF, 0); */ |
| /* setbuf(stdout, NULL); */ |
/* setbuf(stdout, NULL); */ |
| |
|
| Line 476 proctable_exec(ptbl) |
|
| Line 429 proctable_exec(ptbl) |
|
| msg_print("Running fcntl()\n"); |
msg_print("Running fcntl()\n"); |
| } |
} |
| } |
} |
| */ |
*/ |
| |
|
| |
for (k = 0; k < N_FD; k++) { |
| |
if (k > 0) { |
| |
fchmod(k, 030620); |
| |
fcntl(k, F_SETFL, O_NONBLOCK|O_NDELAY); |
| |
} |
| |
} |
| |
|
| execvp(ptbl[i]->argv[0], ptbl[i]->argv); |
execvp(ptbl[i]->argv[0], ptbl[i]->argv); |
| //execve(ptbl[i]->argv[0], ptbl[i]->argv, environ); |
//execve(ptbl[i]->argv[0], ptbl[i]->argv, environ); |
| Line 624 proctable_read(p_ptbl, p_fds) |
|
| Line 584 proctable_read(p_ptbl, p_fds) |
|
| i, k, datasize); |
i, k, datasize); |
| #endif |
#endif |
| |
|
| if (datasize == 0) |
if (datasize == 0) { |
| close((*p_ptbl)[i]->fd[k].pipe[0]); |
close((*p_ptbl)[i]->fd[k].pipe[0]); |
| |
#if DEBUG |
| |
msg_debug_print("proctable_read(): close(%d)\n", |
| |
(*p_ptbl)[i]->fd[k].pipe[0]); |
| |
#endif |
| |
} |
| |
|
| if (datasize < 0) { |
if (datasize < 0) { |
| #if DEBUG |
#if DEBUG |
| Line 706 proctable_read(p_ptbl, p_fds) |
|
| Line 671 proctable_read(p_ptbl, p_fds) |
|
| if (datasize == 0) |
if (datasize == 0) |
| break; |
break; |
| } |
} |
| |
|
| return 0; |
return 0; |
| } |
} |
| |
|
| Line 715 proctable_wait(p_ptbl) |
|
| Line 681 proctable_wait(p_ptbl) |
|
| PROCTABLE *p_ptbl; |
PROCTABLE *p_ptbl; |
| { |
{ |
| register int i, k, proc_n_link, f_wait_call = 0; |
register int i, k, proc_n_link, f_wait_call = 0; |
| |
int pid = 0; |
| |
|
| for (i = 0; (*p_ptbl)[i] != NULL; i++) { |
for (i = 0; (*p_ptbl)[i] != NULL; i++) { |
| |
if (! i) |
| |
continue; |
| |
|
| proc_n_link = 0; |
proc_n_link = 0; |
| for (k = 0; k < N_FD; k++) |
for (k = 0; k < N_FD; k++) |
| Line 734 proctable_wait(p_ptbl) |
|
| Line 703 proctable_wait(p_ptbl) |
|
| |
|
| if (f_wait_call != 0) { |
if (f_wait_call != 0) { |
| int status; |
int status; |
| int pid; |
|
| |
|
| #if DEBUG |
#if DEBUG |
| msg_debug_print("proctable_wait(): f_wait_call == 1, calling wait()\n"); |
msg_debug_print("proctable_wait(): f_wait_call == 1, calling wait()\n"); |
| Line 747 proctable_wait(p_ptbl) |
|
| Line 715 proctable_wait(p_ptbl) |
|
| |
|
| switch (pid) { |
switch (pid) { |
| case -1: |
case -1: |
| |
#if 0 |
| msg_error_print("proctable_wait(): " |
msg_error_print("proctable_wait(): " |
| "waitpid() failure: %s\n", strerror(errno)); |
"waitpid() failure: %s\n", strerror(errno)); |
| exit(1); |
#endif |
| break; |
break; |
| |
|
| case 0: // no child available |
case 0: |
| msg_warn_print("proctable_wait(): " |
msg_warn_print("proctable_wait(): " |
| "waitpid() warning: no child available\n"); |
"waitpid() warning: no child available\n"); |
| break; |
break; |
| Line 806 proctable_wait(p_ptbl) |
|
| Line 775 proctable_wait(p_ptbl) |
|
| #endif |
#endif |
| } |
} |
| break; |
break; |
| } /* switch (pid) {} */ |
} /* switch (pid) */ |
| } |
} |
| return 0; |
|
| |
|
| |
return pid; |
| } |
} |
| |
|