ObjFW
Loading...
Searching...
No Matches
OFSubprocess.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This file is part of ObjFW. It may be distributed under the terms of the
7 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8 * the packaging of this file.
9 *
10 * Alternatively, it may be distributed under the terms of the GNU General
11 * Public License, either version 2 or 3, which can be found in the file
12 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13 * file.
14 */
15
16#ifndef __STDC_LIMIT_MACROS
17# define __STDC_LIMIT_MACROS
18#endif
19#ifndef __STDC_CONSTANT_MACROS
20# define __STDC_CONSTANT_MACROS
21#endif
22
23#include "objfw-defs.h"
24
25#ifdef OF_HAVE_SYS_TYPES_H
26# include <sys/types.h>
27#endif
28
29#import "OFStream.h"
30#import "OFKernelEventObserver.h"
31#import "OFString.h"
32
33#ifdef OF_WINDOWS
34# include <windows.h>
35#endif
36
37OF_ASSUME_NONNULL_BEGIN
38
39@class OFArray OF_GENERIC(ObjectType);
40@class OFDictionary OF_GENERIC(KeyType, ObjectType);
41
47OF_SUBCLASSING_RESTRICTED
49#ifndef OF_WINDOWS
51#endif
52{
53#ifndef OF_WINDOWS
54 pid_t _pid;
55 int _readPipe[2], _writePipe[2];
56#else
57 HANDLE _handle, _readPipe[2], _writePipe[2];
58#endif
59 int _status;
60 bool _atEndOfStream;
61}
62
71+ (instancetype)subprocessWithProgram: (OFString *)program;
72
82+ (instancetype)
83 subprocessWithProgram: (OFString *)program
84 arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments;
85
97+ (instancetype)
98 subprocessWithProgram: (OFString *)program
99 programName: (OFString *)programName
100 arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments;
101
118+ (instancetype)
119 subprocessWithProgram: (OFString *)program
120 programName: (OFString *)programName
121 arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments
122 environment: (nullable OFDictionary
123 OF_GENERIC(OFString *, OFString *) *)environment;
124
125- (instancetype)init OF_UNAVAILABLE;
126
135- (instancetype)initWithProgram: (OFString *)program;
136
146- (instancetype)
147 initWithProgram: (OFString *)program
148 arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments;
149
161- (instancetype)
162 initWithProgram: (OFString *)program
163 programName: (OFString *)programName
164 arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments;
165
183- (instancetype)
184 initWithProgram: (OFString *)program
185 programName: (OFString *)programName
186 arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments
187 environment: (nullable OFDictionary
188 OF_GENERIC(OFString *, OFString *) *)environment
189 OF_DESIGNATED_INITIALIZER;
190
200- (void)closeForWriting;
201
211- (int)waitForTermination;
212@end
213
214OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition OFArray.h:105
An abstract class for storing objects in a dictionary.
Definition OFDictionary.h:80
A base class for different types of streams.
Definition OFStream.h:188
A class for handling strings.
Definition OFString.h:135
A class for stream-like communication with a newly created subprocess.
Definition OFSubprocess.h:49
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
Definition OFKernelEventObserver.h:84
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
Definition OFKernelEventObserver.h:99