~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/i.photo.2image/find.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <unistd.h>
 
3
#include <sys/types.h>
 
4
#ifdef __MINGW32__
 
5
#include <process.h>
 
6
#else
 
7
#include <sys/wait.h>
 
8
#endif
 
9
#include <grass/gis.h>
 
10
#include "globals.h"
 
11
 
 
12
 
 
13
/*
 
14
 * run etc/i.find command in background to find all cell, vect files
 
15
 * in the target location.
 
16
 */
 
17
int find_target_files(void)
 
18
{
 
19
    int pid, w, status;
 
20
 
 
21
    select_target_env();
 
22
    pid = G_fork();             /* use G_fork() to inhibit signals */
 
23
    if (pid < 0) {
 
24
        perror("fork");
 
25
        exit(1);
 
26
    }
 
27
 
 
28
    /*
 
29
     * parent waits for child. this wait will be short since child
 
30
     * simply forks and exits. The grandchild runs in background
 
31
     * and grandma continues
 
32
     */
 
33
    if (pid) {
 
34
        while ((w = wait(&status)) != pid && w != -1) ;
 
35
    }
 
36
    else {
 
37
        char command[1024];
 
38
 
 
39
        sprintf(command, "%s/etc/i.find", G_gisbase());
 
40
        if (fork())
 
41
            exit(0);            /* go into background */
 
42
        execl(command, "i.find",
 
43
              G_location(), G_mapset(),
 
44
              "cell", cell_list, "dig", vect_list, (char *)0);
 
45
    }
 
46
    select_current_env();
 
47
 
 
48
    return 0;
 
49
}