~ubuntu-branches/ubuntu/trusty/cctools/trusty-proposed

« back to all changes in this revision

Viewing changes to dttools/src/batch_job_condor.c

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2012-03-30 12:40:01 UTC
  • mfrom: (9.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120330124001-ze0lhxm5uwq2e3mo
Tags: 3.4.2-2
Added patch to handle a missing CFLAGS variable in Python's sysconfig
report (Closes: #661658).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include "debug.h"
4
4
#include "itable.h"
5
5
#include "process.h"
 
6
#include "stringtools.h"
6
7
 
7
8
#include <stdlib.h>
8
9
#include <stdio.h>
14
15
batch_job_id_t batch_job_submit_condor(struct batch_queue *q, const char *cmd, const char *args, const char *infile, const char *outfile, const char *errfile, const char *extra_input_files, const char *extra_output_files)
15
16
{
16
17
        FILE *file;
17
 
        char line[BATCH_JOB_LINE_MAX];
18
18
        int njobs;
19
19
        int jobid;
20
20
 
54
54
        if(!file)
55
55
                return -1;
56
56
 
 
57
        char line[BATCH_JOB_LINE_MAX];
57
58
        while(fgets(line, sizeof(line), file)) {
58
59
                if(sscanf(line, "%d job(s) submitted to cluster %d", &njobs, &jobid) == 2) {
59
60
                        pclose(file);
107
108
batch_job_id_t batch_job_wait_condor(struct batch_queue * q, struct batch_job_info * info_out, time_t stoptime)
108
109
{
109
110
        static FILE *logfile = 0;
110
 
        char line[BATCH_JOB_LINE_MAX];
111
111
 
112
112
        if(!logfile) {
113
113
                logfile = fopen(q->logfile, "r");
126
126
 
127
127
                clearerr(logfile);
128
128
 
 
129
                char line[BATCH_JOB_LINE_MAX];
129
130
                while(fgets(line, sizeof(line), logfile)) {
130
131
                        int type, proc, subproc;
131
132
                        batch_job_id_t jobid;
212
213
 
213
214
int batch_job_remove_condor(struct batch_queue *q, batch_job_id_t jobid)
214
215
{
215
 
        char line[256];
216
 
        FILE *file;
217
 
 
218
 
        sprintf(line, "condor_rm %d", jobid);
219
 
 
220
 
        file = popen(line, "r");
 
216
        char *command = string_format("condor_rm %d", jobid);
 
217
 
 
218
        debug(D_DEBUG, "%s", command);
 
219
        FILE *file = popen(command, "r");
 
220
        free(command);
221
221
        if(!file) {
222
 
                debug(D_DEBUG, "couldn't run %s", line);
 
222
                debug(D_DEBUG, "condor_rm failed");
223
223
                return 0;
224
224
        } else {
225
 
                while(fgets(line, sizeof(line), file)) {
226
 
                        /* nothing */
227
 
                }
 
225
                char buffer[1024];
 
226
                while (fread(buffer, sizeof(char), sizeof(buffer)/sizeof(char), file) > 0)
 
227
                  ;
228
228
                pclose(file);
229
229
                return 1;
230
230
        }