1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.Child;
26 
27 private import glib.Source;
28 private import gtkc.glib;
29 public  import gtkc.glibtypes;
30 
31 
32 public struct Child
33 {
34 	/**
35 	 */
36 
37 	/**
38 	 * Sets a function to be called when the child indicated by @pid
39 	 * exits, at a default priority, #G_PRIORITY_DEFAULT.
40 	 *
41 	 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
42 	 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
43 	 * the spawn function for the child watching to work.
44 	 *
45 	 * Note that on platforms where #GPid must be explicitly closed
46 	 * (see g_spawn_close_pid()) @pid must not be closed while the
47 	 * source is still active. Typically, you will want to call
48 	 * g_spawn_close_pid() in the callback function for the source.
49 	 *
50 	 * GLib supports only a single callback per process id.
51 	 *
52 	 * This internally creates a main loop source using
53 	 * g_child_watch_source_new() and attaches it to the main loop context
54 	 * using g_source_attach(). You can do these steps manually if you
55 	 * need greater control.
56 	 *
57 	 * Params:
58 	 *     pid = process id to watch. On POSIX the positive pid of a child
59 	 *         process. On Windows a handle for a process (which doesn't have to be
60 	 *         a child).
61 	 *     funct = function to call
62 	 *     data = data to pass to @function
63 	 *
64 	 * Return: the ID (greater than 0) of the event source.
65 	 *
66 	 * Since: 2.4
67 	 */
68 	public static uint childWatchAdd(GPid pid, GChildWatchFunc funct, void* data)
69 	{
70 		return g_child_watch_add(pid, funct, data);
71 	}
72 
73 	/**
74 	 * Sets a function to be called when the child indicated by @pid
75 	 * exits, at the priority @priority.
76 	 *
77 	 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
78 	 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
79 	 * the spawn function for the child watching to work.
80 	 *
81 	 * In many programs, you will want to call g_spawn_check_exit_status()
82 	 * in the callback to determine whether or not the child exited
83 	 * successfully.
84 	 *
85 	 * Also, note that on platforms where #GPid must be explicitly closed
86 	 * (see g_spawn_close_pid()) @pid must not be closed while the source
87 	 * is still active.  Typically, you should invoke g_spawn_close_pid()
88 	 * in the callback function for the source.
89 	 *
90 	 * GLib supports only a single callback per process id.
91 	 *
92 	 * This internally creates a main loop source using
93 	 * g_child_watch_source_new() and attaches it to the main loop context
94 	 * using g_source_attach(). You can do these steps manually if you
95 	 * need greater control.
96 	 *
97 	 * Params:
98 	 *     priority = the priority of the idle source. Typically this will be in the
99 	 *         range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
100 	 *     pid = process to watch. On POSIX the positive pid of a child process. On
101 	 *         Windows a handle for a process (which doesn't have to be a child).
102 	 *     funct = function to call
103 	 *     data = data to pass to @function
104 	 *     notify = function to call when the idle is removed, or %NULL
105 	 *
106 	 * Return: the ID (greater than 0) of the event source.
107 	 *
108 	 * Since: 2.4
109 	 */
110 	public static uint childWatchAddFull(int priority, GPid pid, GChildWatchFunc funct, void* data, GDestroyNotify notify)
111 	{
112 		return g_child_watch_add_full(priority, pid, funct, data, notify);
113 	}
114 
115 	/**
116 	 * Creates a new child_watch source.
117 	 *
118 	 * The source will not initially be associated with any #GMainContext
119 	 * and must be added to one with g_source_attach() before it will be
120 	 * executed.
121 	 *
122 	 * Note that child watch sources can only be used in conjunction with
123 	 * `g_spawn...` when the %G_SPAWN_DO_NOT_REAP_CHILD flag is used.
124 	 *
125 	 * Note that on platforms where #GPid must be explicitly closed
126 	 * (see g_spawn_close_pid()) @pid must not be closed while the
127 	 * source is still active. Typically, you will want to call
128 	 * g_spawn_close_pid() in the callback function for the source.
129 	 *
130 	 * Note further that using g_child_watch_source_new() is not
131 	 * compatible with calling `waitpid` with a nonpositive first
132 	 * argument in the application. Calling waitpid() for individual
133 	 * pids will still work fine.
134 	 *
135 	 * Similarly, on POSIX platforms, the @pid passed to this function must
136 	 * be greater than 0 (i.e. this function must wait for a specific child,
137 	 * and cannot wait for one of many children by using a nonpositive argument).
138 	 *
139 	 * Params:
140 	 *     pid = process to watch. On POSIX the positive pid of a child process. On
141 	 *         Windows a handle for a process (which doesn't have to be a child).
142 	 *
143 	 * Return: the newly-created child watch source
144 	 *
145 	 * Since: 2.4
146 	 */
147 	public static Source childWatchSourceNew(GPid pid)
148 	{
149 		auto p = g_child_watch_source_new(pid);
150 		
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 		
156 		return new Source(cast(GSource*) p);
157 	}
158 }