File: syste.c

package info (click to toggle)
icmake 6.30-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,360 kB
  • ctags: 1,415
  • sloc: ansic: 7,727; makefile: 1,465; sh: 244; asm: 126; cpp: 39
file content (43 lines) | stat: -rw-r--r-- 1,029 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
\funcref{fun\_system}{void fun\_system ()}
    {}
    {}
    {}
    {fun\_exec()}
    {funsyste.c}
    {

        This function expects a system string as last pushed {\em e\_str}
        value. The string is executed through a {\em system()} call (if this
        fails, an error is issued).

    }
*/

#include "builtin.ih"

void fun_system ()
{
    int  mode = intValue(top());            /* get mode arg */
    char const *cmd = stringStr(top() - 1); /* get cmd string */

    if (echo)                               /* re-echo if requested */
        puts (cmd);

    fflush (stdout);

#ifdef MSDOS
    _heapmin ();                            /* max memory under DOS */
#endif

    {
        int ret;                            /* system() return */
    
        ret = system(cmd);                  /* do system call */

        if (ret && P_CHECKMODE(mode))       /* terminate upon failure? */
            error ("system - failure of system call (status %d)", ret);

        reg = intConstructor_i(ret);        
    }
}