#include "unix_sys_utils.hpp"
#include "analyze.hpp"
#include "tm_timer.hpp"
#include <fcntl.h>
#include <pthread.h>
#include <pwd.h>
#include <spawn.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
Go to the source code of this file.
◆ unix_get_process_id()
SN unix_get_process_id |
( |
| ) |
|
◆ _ts_malloc()
void * _ts_malloc |
( |
int | n | ) |
|
Definition at line 51 of file unix_sys_utils.cpp.
51 {
54}
The list class represents a linked list.
static _mutex _ts_memory_lock
◆ _ts_free()
◆ _background_read_task()
Definition at line 139 of file unix_sys_utils.cpp.
139 {
142 int n =
c->buffer_size;
143 char*
b =
A (
c->buffer);
145 do {
147
148 if (
m > 0)
c->data.append (
b,
m);
150 if (close (fd) != 0)
c->status= -1;
151 }
154}
bool read(string s, int &i, const char *test)
T * A(array< T > a)
Get a pointer to the first element of the array.
◆ _background_write_task()
Definition at line 158 of file unix_sys_utils.cpp.
158 {
161 const char*
d =
c->data.a;
162 int n =
c->buffer_size;
163 int t= (
c->data).n,
k= 0,
o= 0;
164 if (
t == 0)
return (
void*)
NULL;
165 if (n == 0) {
168 }
169 do {
171
172 o= write (fd, (
void*) (
d +
k),
m);
173
176 close (fd);
178 }
180 if (close (fd) != 0)
c->status= -1;
181 }
182 }
while (
o > 0 &&
k <
t);
184}
SI min(SI i, SI j)
Returns the minimum of two signed integers.
◆ _unix_system_warn()
◆ unix_system()
Definition at line 202 of file unix_sys_utils.cpp.
203 {
204
205
206
207
208
209 if (
N (
arg) == 0)
return 0;
216 for (
int i= 0; i <
n_in; i++) {
218 pp_in[i].out ()) != 0)
219 return -1;
223 return -1;
225 pp_in[i].in ()) != 0)
226 return -1;
227 }
228 }
229 for (
int i= 0; i <
n_out; i++) {
232 return -1;
235 return -1;
238 return -1;
239 }
241 for (
int j= 0;
j <
N (
arg);
j++)
242 for (
int i= 0; i <
n_in; i++)
251 int status=
255 if (status != 0) {
256 return -1;
257 }
258
259 for (
int i= 0; i <
n_in; i++)
260 close (
pp_in[i].in ());
261 for (
int i= 0; i <
n_out; i++)
263
264
267 for (
int i= 0; i <
n_in; i++) {
271 return -1;
272 }
273
274
277 for (
int i= 0; i <
n_out; i++) {
281 return -1;
282 }
283
291 }
292 }
293
294
297 for (
int i= 0; i <
n_in; i++) {
300 }
301 for (
int i= 0; i <
n_out; i++) {
305 }
306
310}
string recompose(array< string > a, string sep)
string replace(string s, string what, string by)
int N(array< T > a)
Get the length of the array.
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
void tm_delete_array(C *Ptr)
char * as_charp(string s)
string as_string(int16_t i)
static void * _background_write_task(void *channel_as_void_ptr)
static void * _background_read_task(void *channel_as_void_ptr)
static void _unix_system_warn(pid_t pid, string which, string msg)
◆ unix_get_login()
Definition at line 313 of file unix_sys_utils.cpp.
313 {
317}
list(T item)
Construct a new list object with a single item.
◆ unix_get_username()
Definition at line 320 of file unix_sys_utils.cpp.
320 {
324}
array< string > tokenize(string s, string sep)
◆ environ
◆ _ts_memory_lock