main.h
author viric <viriketo@gmail.com>
Fri, 25 Mar 2016 16:19:23 +0100
changeset 347 79b87e385bc5
parent 340 11c5a9e7b9a8
child 369 040912c941e4
permissions -rw-r--r--
Make ts respect TMPDIR for output files. It was using hardcoded /tmp.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
339
350600fb772f Adding some more headers (I found them on disk, dated 16/5/2014)
viric <viriketo@gmail.com>
parents: 334
diff changeset
     1
/*
350600fb772f Adding some more headers (I found them on disk, dated 16/5/2014)
viric <viriketo@gmail.com>
parents: 334
diff changeset
     2
    Task Spooler - a task queue system for the unix user
350600fb772f Adding some more headers (I found them on disk, dated 16/5/2014)
viric <viriketo@gmail.com>
parents: 334
diff changeset
     3
    Copyright (C) 2007-2013  Lluís Batlle i Rossell
350600fb772f Adding some more headers (I found them on disk, dated 16/5/2014)
viric <viriketo@gmail.com>
parents: 334
diff changeset
     4
350600fb772f Adding some more headers (I found them on disk, dated 16/5/2014)
viric <viriketo@gmail.com>
parents: 334
diff changeset
     5
    Please find the license in the provided COPYING file.
350600fb772f Adding some more headers (I found them on disk, dated 16/5/2014)
viric <viriketo@gmail.com>
parents: 334
diff changeset
     6
*/
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
     7
enum
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
     8
{
260
ecd09b351170 Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents: 259
diff changeset
     9
    CMD_LEN=500,
328
7f066fdc43c5 Setting the protocol version to 730. That matches better when it's introduced:
viric <viriketo@gmail.com>
parents: 315
diff changeset
    10
    PROTOCOL_VERSION=730
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    11
};
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    12
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    13
enum msg_types
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    14
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    15
    KILL_SERVER,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    16
    NEWJOB,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    17
    NEWJOB_OK,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    18
    RUNJOB,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    19
    RUNJOB_OK,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    20
    ENDJOB,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    21
    LIST,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    22
    LIST_LINE,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    23
    CLEAR_FINISHED,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    24
    ASK_OUTPUT,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    25
    ANSWER_OUTPUT,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    26
    REMOVEJOB,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    27
    REMOVEJOB_OK,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    28
    WAITJOB,
226
472ab90fd6a1 Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents: 219
diff changeset
    29
    WAIT_RUNNING_JOB,
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    30
    WAITJOB_OK,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    31
    URGENT,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    32
    URGENT_OK,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    33
    GET_STATE,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    34
    ANSWER_STATE,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    35
    SWAP_JOBS,
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
    36
    SWAP_JOBS_OK,
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
    37
    INFO,
219
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 218
diff changeset
    38
    INFO_DATA,
253
e9b153f4ae40 Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents: 252
diff changeset
    39
    SET_MAX_SLOTS,
e9b153f4ae40 Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents: 252
diff changeset
    40
    GET_MAX_SLOTS,
260
ecd09b351170 Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents: 259
diff changeset
    41
    GET_MAX_SLOTS_OK,
ecd09b351170 Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents: 259
diff changeset
    42
    GET_VERSION,
295
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
    43
    VERSION,
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
    44
    NEWJOB_NOK
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    45
};
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
    46
31
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    47
enum Request
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    48
{
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    49
    c_QUEUE,
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    50
    c_TAIL,
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    51
    c_KILL_SERVER,
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    52
    c_LIST,
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    53
    c_CLEAR_FINISHED,
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    54
    c_SHOW_HELP,
37
f2f6c6f0e86f Added version.
viric@llimona
parents: 35
diff changeset
    55
    c_SHOW_VERSION,
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
    56
    c_CAT,
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
    57
    c_SHOW_OUTPUT_FILE,
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
    58
    c_SHOW_PID,
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
    59
    c_REMOVEJOB,
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
    60
    c_WAITJOB,
63
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
    61
    c_URGENT,
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 65
diff changeset
    62
    c_GET_STATE,
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
    63
    c_SWAP_JOBS,
219
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 218
diff changeset
    64
    c_INFO,
253
e9b153f4ae40 Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents: 252
diff changeset
    65
    c_SET_MAX_SLOTS,
340
11c5a9e7b9a8 Adding -k, kill job (SIGTERM to process group).
viric <viriketo@gmail.com>
parents: 339
diff changeset
    66
    c_GET_MAX_SLOTS,
11c5a9e7b9a8 Adding -k, kill job (SIGTERM to process group).
viric <viriketo@gmail.com>
parents: 339
diff changeset
    67
    c_KILL_JOB
31
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    68
};
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    69
30
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 28
diff changeset
    70
struct Command_line {
31
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
    71
    enum Request request;
30
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 28
diff changeset
    72
    int need_server;
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 28
diff changeset
    73
    int store_output;
305
365f3598d010 Adding the functionality of keeping stderr apart. For Jan Šmydke.
viric <viriketo@gmail.com>
parents: 295
diff changeset
    74
    int stderr_apart;
30
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 28
diff changeset
    75
    int should_go_background;
55
678ca291d545 Now the '-nf' doesn't leave a job in 'finished' state.
viric@llimona
parents: 53
diff changeset
    76
    int should_keep_finished;
71
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
    77
    int send_output_by_mail;
65
dced0efccc19 Added gzip output.
viric@llimona
parents: 63
diff changeset
    78
    int gzip;
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 254
diff changeset
    79
    int do_depend;
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 254
diff changeset
    80
    int depend_on; /* -1 means depend on previous */
219
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 218
diff changeset
    81
    int max_slots; /* How many jobs to run at once */
71
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
    82
    int jobid; /* When queuing a job, main.c will fill it automatically from
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
    83
                  the server answer to NEWJOB */
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 65
diff changeset
    84
    int jobid2;
295
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
    85
    int wait_enqueuing;
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 65
diff changeset
    86
    struct {
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 65
diff changeset
    87
        char **array;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 65
diff changeset
    88
        int num;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 65
diff changeset
    89
    } command;
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    90
    char *label;
315
2b3ed8fdfb12 Implementing the num_slots for newjob in the messages, but the server still does
viric <viriketo@gmail.com>
parents: 314
diff changeset
    91
    int num_slots; /* Slots for the job to use. Default 1 */
30
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 28
diff changeset
    92
};
3
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
    93
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
    94
enum Process_type {
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
    95
    CLIENT,
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
    96
    SERVER
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
    97
};
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
    98
30
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 28
diff changeset
    99
extern struct Command_line command_line;
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   100
extern int server_socket;
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
   101
extern enum Process_type process_type;
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   102
extern int server_socket; /* Used in the client */
3
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   103
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   104
struct msg;
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   105
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   106
enum Jobstate
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   107
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   108
    QUEUED,
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   109
    RUNNING,
156
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   110
    FINISHED,
287
b3c38ff8f41a An implementation that looks like working for the queue limit and client
viric <viriketo@gmail.com>
parents: 282
diff changeset
   111
    SKIPPED,
b3c38ff8f41a An implementation that looks like working for the queue limit and client
viric <viriketo@gmail.com>
parents: 282
diff changeset
   112
    HOLDING_CLIENT
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   113
};
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   114
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   115
struct msg
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   116
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   117
    enum msg_types type;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   118
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   119
    union
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   120
    {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   121
        struct {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   122
            int command_size;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   123
            int store_output;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   124
            int should_keep_finished;
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
   125
            int label_size;
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   126
            int env_size;
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 254
diff changeset
   127
            int do_depend;
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 254
diff changeset
   128
            int depend_on; /* -1 means depend on previous */
295
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   129
            int wait_enqueuing;
315
2b3ed8fdfb12 Implementing the num_slots for newjob in the messages, but the server still does
viric <viriketo@gmail.com>
parents: 314
diff changeset
   130
            int num_slots;
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   131
        } newjob;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   132
        struct {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   133
            int ofilename_size;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   134
            int store_output;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   135
            int pid;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   136
        } output;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   137
        int jobid;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   138
        struct Result {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   139
            int errorlevel;
246
239b28c0cca9 Adding information on the exit status (signal/exit code).
viric@mandarina
parents: 235
diff changeset
   140
            int died_by_signal;
239b28c0cca9 Adding information on the exit status (signal/exit code).
viric@mandarina
parents: 235
diff changeset
   141
            int signal;
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   142
            float user_ms;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   143
            float system_ms;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   144
            float real_ms;
156
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   145
            int skipped;
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   146
        } result;
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   147
        int size;
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   148
        enum Jobstate state;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   149
        struct {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   150
            int jobid1;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   151
            int jobid2;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   152
        } swap;
314
d137a7b333ce Fixing some tabs/spaces.
viric <viriketo@gmail.com>
parents: 305
diff changeset
   153
        int last_errorlevel;
d137a7b333ce Fixing some tabs/spaces.
viric <viriketo@gmail.com>
parents: 305
diff changeset
   154
        int max_slots;
d137a7b333ce Fixing some tabs/spaces.
viric <viriketo@gmail.com>
parents: 305
diff changeset
   155
        int version;
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   156
    } u;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   157
};
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   158
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   159
struct Procinfo
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   160
{
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   161
    char *ptr;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   162
    int nchars;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   163
    int allocchars;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   164
    struct timeval enqueue_time;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   165
    struct timeval start_time;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   166
    struct timeval end_time;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   167
};
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   168
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   169
struct Job
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   170
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   171
    struct Job *next;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   172
    int jobid;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   173
    char *command;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   174
    enum Jobstate state;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   175
    struct Result result; /* Defined in msg.h */
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   176
    char *output_filename;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   177
    int store_output;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   178
    int pid;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   179
    int should_keep_finished;
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 254
diff changeset
   180
    int do_depend;
218
f084c8de313f First attempt at multiple slot running.
viric@mandarina
parents: 203
diff changeset
   181
    int depend_on;
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 254
diff changeset
   182
    int *notify_errorlevel_to;
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 254
diff changeset
   183
    int notify_errorlevel_to_size;
218
f084c8de313f First attempt at multiple slot running.
viric@mandarina
parents: 203
diff changeset
   184
    int dependency_errorlevel;
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
   185
    char *label;
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   186
    struct Procinfo info;
315
2b3ed8fdfb12 Implementing the num_slots for newjob in the messages, but the server still does
viric <viriketo@gmail.com>
parents: 314
diff changeset
   187
    int num_slots;
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   188
};
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   189
295
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   190
enum ExitCodes
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   191
{
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   192
    EXITCODE_OK            =  0,
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   193
    EXITCODE_UNKNOWN_ERROR = -1,
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   194
    EXITCODE_QUEUE_FULL    = 2
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   195
};
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 287
diff changeset
   196
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   197
3
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   198
/* client.c */
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 65
diff changeset
   199
void c_new_job();
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   200
void c_list_jobs();
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   201
void c_shutdown_server();
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 3
diff changeset
   202
void c_wait_server_lines();
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   203
void c_clear_finished();
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 65
diff changeset
   204
int c_wait_server_commands();
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   205
void c_send_runjob_ok(const char *ofname, int pid);
174
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 173
diff changeset
   206
int c_tail();
203
664044b1de73 Making '-c' to behave as 'tail -f', but showing *all* the file.
lbatlle@npdl268.bpo.hp.com
parents: 174
diff changeset
   207
int c_cat();
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   208
void c_show_output_file();
41
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   209
void c_remove_job();
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   210
void c_show_pid();
340
11c5a9e7b9a8 Adding -k, kill job (SIGTERM to process group).
viric <viriketo@gmail.com>
parents: 339
diff changeset
   211
void c_kill_job();
51
aa6e05d77537 '-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents: 44
diff changeset
   212
int c_wait_job();
226
472ab90fd6a1 Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents: 219
diff changeset
   213
int c_wait_running_job();
174
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 173
diff changeset
   214
int c_wait_job_recv();
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   215
void c_move_urgent();
62
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   216
int c_wait_newjob_ok();
63
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   217
void c_get_state();
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 65
diff changeset
   218
void c_swap_jobs();
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   219
void c_show_info();
71
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
   220
char *build_command_string();
219
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 218
diff changeset
   221
void c_send_max_slots(int max_slots);
253
e9b153f4ae40 Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents: 252
diff changeset
   222
void c_get_max_slots();
260
ecd09b351170 Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents: 259
diff changeset
   223
void c_check_version();
3
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   224
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   225
/* jobs.c */
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   226
void s_list(int s);
18
af4898956964 Now commands of any-length are accepted.
viric@llimona
parents: 8
diff changeset
   227
int s_newjob(int s, struct msg *m);
3
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   228
void s_removejob(int jobid);
218
f084c8de313f First attempt at multiple slot running.
viric@mandarina
parents: 203
diff changeset
   229
void job_finished(const struct Result *result, int jobid);
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   230
int next_run_job();
218
f084c8de313f First attempt at multiple slot running.
viric@mandarina
parents: 203
diff changeset
   231
void s_mark_job_running(int jobid);
20
d85b4c0745fa "-c" added, for clearing the finished tasks' list.
viric@llimona
parents: 19
diff changeset
   232
void s_clear_finished();
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   233
void s_process_runjob_ok(int jobid, char *oname, int pid);
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   234
void s_send_output(int socket, int jobid);
334
e9e212846a89 Fixing a process left, when "-r" is used without jobid.
viric
parents: 328
diff changeset
   235
int s_remove_job(int s, int *jobid);
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   236
void s_remove_notification(int s);
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   237
void check_notify_list(int jobid);
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   238
void s_wait_job(int s, int jobid);
226
472ab90fd6a1 Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents: 219
diff changeset
   239
void s_wait_running_job(int s, int jobid);
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   240
void s_move_urgent(int s, int jobid);
63
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   241
void s_send_state(int s, int jobid);
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 65
diff changeset
   242
void s_swap_jobs(int s, int jobid1, int jobid2);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
   243
void dump_jobs_struct(FILE *out);
254
41252d5e85f5 Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents: 253
diff changeset
   244
void dump_notifies_struct(FILE *out);
120
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   245
void joblist_dump(int fd);
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   246
const char * jstate2string(enum Jobstate s);
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   247
void s_job_info(int s, int jobid);
218
f084c8de313f First attempt at multiple slot running.
viric@mandarina
parents: 203
diff changeset
   248
void s_send_runjob(int s, int jobid);
219
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 218
diff changeset
   249
void s_set_max_slots(int new_max_slots);
253
e9b153f4ae40 Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents: 252
diff changeset
   250
void s_get_max_slots(int s);
252
f0af96f58947 Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents: 251
diff changeset
   251
int job_is_running(int jobid);
287
b3c38ff8f41a An implementation that looks like working for the queue limit and client
viric <viriketo@gmail.com>
parents: 282
diff changeset
   252
int job_is_holding_client(int jobid);
b3c38ff8f41a An implementation that looks like working for the queue limit and client
viric <viriketo@gmail.com>
parents: 282
diff changeset
   253
int wake_hold_client();
3
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   254
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   255
/* server.c */
28
107abb4ec98a Unified socket path, depending on the username and $TMPDIR.
viric@llimona
parents: 27
diff changeset
   256
void server_main(int notify_fd, char *_path);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
   257
void dump_conns_struct(FILE *out);
3
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   258
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   259
/* server_start.c */
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   260
int try_connect(int s);
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   261
void wait_server_up();
2fb8a6bdd024 More code.
viric@llimona
parents:
diff changeset
   262
int ensure_server_up();
25
e9e4babe6262 Now the server is quicly started.
viric@llimona
parents: 22
diff changeset
   263
void notify_parent(int fd);
251
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 246
diff changeset
   264
void create_socket_path(char **path);
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   265
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   266
/* execute.c */
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 65
diff changeset
   267
int run_job();
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   268
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   269
/* client_run.c */
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   270
void c_run_tail(const char *filename);
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   271
void c_run_cat(const char *filename);
71
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
   272
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
   273
/* mail.c */
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
   274
void send_mail(int jobid, int errorlevel, const char *ofname,
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
   275
    const char *command);
73
0c03786ff927 Added TS_ONFINISH.
viric@llimona
parents: 71
diff changeset
   276
void hook_on_finish(int jobid, int errorlevel, const char *ofname,
0c03786ff927 Added TS_ONFINISH.
viric@llimona
parents: 71
diff changeset
   277
    const char *command);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
   278
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
   279
/* error.c */
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
   280
void error(const char *str, ...);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 73
diff changeset
   281
void warning(const char *str, ...);
95
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents: 92
diff changeset
   282
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents: 92
diff changeset
   283
/* signals.c */
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents: 92
diff changeset
   284
void ignore_sigpipe();
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents: 92
diff changeset
   285
void restore_sigmask();
138
00461b7bdf4b Passing SIGINT to the child, if it started.
viric@llimona
parents: 134
diff changeset
   286
void block_sigint();
00461b7bdf4b Passing SIGINT to the child, if it started.
viric@llimona
parents: 134
diff changeset
   287
void unblock_sigint_and_install_handler();
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   288
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   289
/* msg.c */
235
97064e7d2969 Assuring the send/recv loops, which didn't pay attention to data sent in
llbatlle@taga
parents: 226
diff changeset
   290
void send_bytes(const int fd, const char *data, int bytes);
97064e7d2969 Assuring the send/recv loops, which didn't pay attention to data sent in
llbatlle@taga
parents: 226
diff changeset
   291
int recv_bytes(const int fd, char *data, int bytes);
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   292
void send_msg(const int fd, const struct msg *m);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   293
int recv_msg(const int fd, struct msg *m);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   294
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   295
/* msgdump.c */
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   296
void msgdump(FILE *, const struct msg *m);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   297
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   298
/* error.c */
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   299
void error_msg(const struct msg *m, const char *str, ...);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   300
void warning_msg(const struct msg *m, const char *str, ...);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   301
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   302
/* list.c */
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   303
char * joblist_headers();
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents: 114
diff changeset
   304
char * joblist_line(const struct Job *p);
120
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   305
char * joblistdump_torun(const struct Job *p);
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   306
char * joblistdump_headers();
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   307
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   308
/* print.c */
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   309
int fd_nprintf(int fd, int maxsize, const char *fmt, ...);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   310
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   311
/* info.c */
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   312
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   313
void pinfo_dump(const struct Procinfo *p, int fd);
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   314
void pinfo_addinfo(struct Procinfo *p, int maxsize, const char *line, ...);
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   315
void pinfo_free(struct Procinfo *p);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   316
int pinfo_size(const struct Procinfo *p);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   317
void pinfo_set_enqueue_time(struct Procinfo *p);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   318
void pinfo_set_start_time(struct Procinfo *p);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   319
void pinfo_set_end_time(struct Procinfo *p);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   320
float pinfo_time_until_now(const struct Procinfo *p);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 138
diff changeset
   321
float pinfo_time_run(const struct Procinfo *p);
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   322
void pinfo_init(struct Procinfo *p);
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   323
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   324
/* env.c */
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   325
char * get_environment();
173
b572fdd206f4 Adding some code base for our implementation of 'tail'.
viric@llimona
parents: 156
diff changeset
   326
b572fdd206f4 Adding some code base for our implementation of 'tail'.
viric@llimona
parents: 156
diff changeset
   327
/* tail.c */
203
664044b1de73 Making '-c' to behave as 'tail -f', but showing *all* the file.
lbatlle@npdl268.bpo.hp.com
parents: 174
diff changeset
   328
int tail_file(const char *fname, int last_lines);