File: xsystem.hc

package info (click to toggle)
craft 3.5-12
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,172 kB
  • ctags: 1,605
  • sloc: cpp: 3,794; makefile: 2,322; ansic: 857; sh: 842
file content (43 lines) | stat: -rw-r--r-- 643 bytes parent folder | download | duplicates (4)
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
#include "stdlib.h"

#include "xsystem.h"
#include "xfile.h"

#define temp_file_name "jobs~"

int batch (char cmd [])
  {int job_no = 0;

   start_cmd;
   get_job_no;
   return job_no;

.  start_cmd
     {char f_cmd [1024];

      sprintf (f_cmd, "%s &", cmd);
      system  (f_cmd);
     }.

.  get_job_no
     {read_job_info;
      read_no;
     }.

.  read_job_info
     {char cmd [128];

      sprintf (cmd, "csh -c \"jobs -l > %s\"", temp_file_name);
      system  (cmd);
     }.

.  read_no
     {FILE *f;
      char d [128];

      f = fopen (temp_file_name, "r");
      fscanf (f, "%s %d", d, &job_no);
      fclose (f);
     }.
 
  }