~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdlib.h>
2
 
#include <unistd.h>
3
 
#include <signal.h>
4
 
#include <sys/types.h>
5
 
#ifdef __MINGW32__
6
 
#include <process.h>
7
 
#else
8
 
#include <sys/wait.h>
9
 
#endif
10
 
#include <grass/gis.h>
11
 
#include <grass/raster.h>
12
 
#include "globals.h"
13
 
/*
14
 
 * call a subroutine, but as a child process
15
 
 * allowing interrupts for the child
16
 
 */
17
 
 
18
 
int call(int (*function) (), char *msg)
19
 
{
20
 
    int pid;
21
 
    int w, status;
22
 
    char i_msg[80];
23
 
 
24
 
    /*
25
 
     * build interrupt msg
26
 
     */
27
 
    sprintf(i_msg, "Hit %s %s\n", G_unctrl(interrupt_char), msg);
28
 
    /*
29
 
     * make sure all graphics have gotten to the monitor
30
 
     */
31
 
    R_stabilize();
32
 
 
33
 
    /* fork to create child */
34
 
    pid = fork();
35
 
    if (pid < 0) {
36
 
        End_curses();
37
 
        perror("Can't fork");
38
 
        exit(1);
39
 
    }
40
 
 
41
 
    /* parent just waits for child */
42
 
    Curses_allow_interrupts(1);
43
 
    if (pid) {
44
 
        Curses_write_window(PROMPT_WINDOW, 1, 1, i_msg);
45
 
        while ((w = wait(&status)) != pid && w != -1) ;
46
 
        Curses_allow_interrupts(0);
47
 
        Curses_write_window(PROMPT_WINDOW, 1, 1, "\n");
48
 
    }
49
 
 
50
 
    /* child turns on interrupts and calls the function */
51
 
    else {
52
 
        signal(SIGINT, SIG_DFL);
53
 
        (*function) ();
54
 
        exit(0);
55
 
    }
56
 
    return 0;
57
 
}