The R Project SVN R

Rev

Rev 52753 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 52753 Rev 52799
Line 243... Line 243...
243
    }
243
    }
244
    UNPROTECT(1);
244
    UNPROTECT(1);
245
    return (ans);
245
    return (ans);
246
}
246
}
247
 
247
 
248
#ifdef HAVE_POPEN
-
 
249
FILE *R_popen(const char *command, const char *type)
248
FILE *R_popen(const char *command, const char *type)
250
{
249
{
251
    FILE *fp;
250
    FILE *fp;
252
#ifdef __APPLE_CC__
251
#ifdef __APPLE_CC__
253
    /* Luke recommends this to fix PR#1140 */
252
    /* Luke recommends this to fix PR#1140 */
Line 260... Line 259...
260
#else
259
#else
261
    fp = popen(command, type);
260
    fp = popen(command, type);
262
#endif
261
#endif
263
    return fp;
262
    return fp;
264
}
263
}
265
#endif /* HAVE_POPEN */
-
 
266
 
264
 
267
int R_system(const char *command)
265
int R_system(const char *command)
268
{
266
{
269
    int val;
267
    int res;
270
#ifdef __APPLE_CC__
268
#ifdef __APPLE_CC__
271
    /* Luke recommends this to fix PR#1140 */
269
    /* Luke recommends this to fix PR#1140 */
272
    sigset_t ss;
270
    sigset_t ss;
273
    sigemptyset(&ss);
271
    sigemptyset(&ss);
274
    sigaddset(&ss, SIGPROF);
272
    sigaddset(&ss, SIGPROF);
Line 276... Line 274...
276
#ifdef HAVE_AQUA
274
#ifdef HAVE_AQUA
277
    char *cmdcpy;
275
    char *cmdcpy;
278
    if(useaqua) {
276
    if(useaqua) {
279
	/* FIXME, is Cocoa's interface not const char*? */
277
	/* FIXME, is Cocoa's interface not const char*? */
280
	cmdcpy = acopy_string(command);
278
	cmdcpy = acopy_string(command);
281
	val = ptr_CocoaSystem(cmdcpy);
279
	res = ptr_CocoaSystem(cmdcpy);
282
    }
280
    }
283
    else
281
    else
284
#endif
282
#endif
285
    val = system(command);
283
    res = system(command);
286
    sigprocmask(SIG_UNBLOCK, &ss, NULL);
284
    sigprocmask(SIG_UNBLOCK, &ss, NULL);
287
#else
285
#else
288
    val = system(command);
286
    res = system(command);
289
#endif
287
#endif
-
 
288
#ifdef HAVE_SYS_WAIT_H
-
 
289
	if (WIFEXITED(res)) res = WEXITSTATUS(res);
-
 
290
	else res = 0;
-
 
291
#else
-
 
292
	/* assume that this is shifted if a multiple of 256 */
-
 
293
	if ((res % 256) == 0) res = res/256;
-
 
294
#endif
290
    return val;
295
    return res;
291
}
296
}
292
 
297
 
293
#if defined(__APPLE__)
298
#if defined(__APPLE__)
294
# include <crt_externs.h>
299
# include <crt_externs.h>
295
# define environ (*_NSGetEnviron())
300
# define environ (*_NSGetEnviron())