File: spawnerr.c

package info (click to toggle)
icmake 6.22-7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,148 kB
  • ctags: 1,042
  • sloc: ansic: 9,241; makefile: 1,134; sh: 235; asm: 126
file content (48 lines) | stat: -rw-r--r-- 1,199 bytes parent folder | download | duplicates (5)
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
44
45
46
47
48
/*
\funcref{spawn\_err}{void spawn\_err (\params)}
    {
        {char}{*progname}{program name}
    }
    {}
    {error()}
    {}
    {spawnerr.c}
    {

        This function can be called when an {\em exec()} or {\em spawn()} call
        indicates failure (by returning -1). Argument {\em progname} should
        indicate the program which should have been executed.

        An appropriate error message is printed and the program is halted.

    }
*/

#include "icrssdef.h"
#include "../icm.h"
#include <errno.h>

void spawn_err (progname)
char *progname;
{
    static char
        errmsg [] = "Can't exec %s: %s";

    switch (errno)
    {
        case E2BIG:
            error (errmsg, progname, "command line too big");
        case EACCES:
            error (errmsg, progname, "access denied");
        case EMFILE:
            error (errmsg, progname, "too many open files");
        case ENOENT:
            error (errmsg, progname, "no such file");
        case ENOEXEC:
            error (errmsg, progname, "exec file format");
        case ENOMEM:
            error (errmsg, progname, "out of memory");
        default:
            error (errmsg, progname, "unknown error");
    }
}