Add API: set-wrappid-path.
[wrappi.git] / APIs / processes.api
1 (* wrappi -*- tuareg -*-
2  * Copyright (C) 2011-2012 Red Hat Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *)
18
19 (*
20 system_object process
21   dir_list "/proc/[1-9]*"
22
23   constructor <<
24     $pid = atoi ($basename);
25   >>
26
27   property int pid (* implicit *)
28
29   property string short_command
30   <<
31     // some code to parse $filename/stat
32   >>
33   property char state
34   <<
35     // some code to parse $filename/stat
36   >>
37
38   writable property foo << ... >>
39
40   method err kill (signal sig)
41   <<
42     return kill ($pid, sig);
43   >>
44   method bool exists ()
45   <<
46     int r = kill ($pid, 0);
47     if (r == 0)
48       return 1;
49     if (r == -1 && errno == ESRCH)
50       return 0;
51     save_errno ();
52     return -1;
53   >>
54 *)