source: appstream-generator/build/girepo/glib/Child.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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