#include "rle_config.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/wait.h>
#include <errno.h>
Go to the source code of this file.
#define _XOPEN_SOURCE /* Make sure fdopen() is in stdio.h */ |
static FILE* my_popen |
( |
| ) |
|
|
static |
static FILE* my_popen |
( |
char * |
cmd, |
|
|
char * |
mode, |
|
|
int * |
pid |
|
) |
| |
|
static |
Definition at line 256 of file rle_open_f.c.
267 if ( *mode !=
'r' && *mode !=
'w' )
273 if ( pipe(pipefd) < 0 )
279 if ( (thepid = fork()) < 0 )
285 else if (thepid == 0) {
299 for ( i = 3; i < 64; i++ )
303 if ( execl(
"/bin/sh",
"sh",
"-c", cmd, NULL) < 0 )
313 retfile = fdopen( pipefd[0], mode );
317 retfile = fdopen( pipefd[1], mode );
void rle_close_f |
( |
FILE * |
fd | ) |
|
FILE* rle_open_f |
( |
char * |
prog_name, |
|
|
char * |
file_name, |
|
|
char * |
mode |
|
) |
| |
Definition at line 216 of file rle_open_f.c.
FILE * rle_open_f_noexit(char *prog_name, char *file_name, char *mode)
static Panel_item file_name
FILE* rle_open_f_noexit |
( |
char * |
prog_name, |
|
|
char * |
file_name, |
|
|
char * |
mode |
|
) |
| |
Definition at line 57 of file rle_open_f.c.
Referenced by RLE::open:.
66 #ifdef STDIO_NEEDS_BINARY
70 mode_string[0] = mode[0];
72 strcpy( mode_string + 2, mode + 1 );
76 if ( *mode ==
'w' || *mode ==
'a' )
96 if (kill(
pids[i], 0) < 0) {
97 int opid =
pids[
i], pid = 0;
103 while (pid != opid) {
106 j < catching_children &&
pids[j] != pid;
110 fprintf( stderr,
"Reaping %d at %d for %d at %d\n",
116 if ( j < catching_children ) {
141 err_str =
"%s: can't invoke <<%s>> for %s: ";
147 fprintf( stderr,
"Forking %d at %d\n",
148 thepid, catching_children );
151 pids[catching_children++] = thepid;
156 else if ( cp >
file_name && *cp ==
'.' && *(cp + 1) ==
'Z' )
160 if ( combuf == NULL )
162 err_str =
"%s: out of memory opening (compressed) %s for %s";
167 sprintf( combuf,
"compress > %s",
file_name );
168 else if ( *mode ==
'a' )
169 sprintf( combuf,
"compress >> %s",
file_name );
171 sprintf( combuf,
"compress -d < %s",
file_name );
173 fp =
my_popen( combuf, mode, &thepid );
179 "%s: can't invoke 'compress' program, trying to open %s for %s";
185 fprintf( stderr,
"Forking %d at %d\n", thepid, catching_children );
188 pids[catching_children++] = thepid;
195 if ( (fp = fopen(
file_name, mode)) == NULL )
197 err_str =
"%s: can't open %s for %s: ";
205 fprintf( stderr, err_str,
207 (*mode ==
'w') ?
"output" :
208 (*mode ==
'a') ?
"append" :
static int catching_children
static Panel_item file_name
int catching_children = 0 |
|
static |