File: popen_plus.hpp

package info (click to toggle)
cg3 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,684 kB
  • sloc: cpp: 26,476; xml: 6,139; perl: 1,398; lisp: 1,091; ansic: 178; sh: 47; python: 26; makefile: 14
file content (51 lines) | stat: -rw-r--r-- 1,310 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 ** Author: Hamid Alipour http://codingrecipes.com http://twitter.com/code_head
 ** SQLite style license:
 **
 ** 2001 September 15
 **
 ** The author disclaims copyright to this source code.  In place of
 ** a legal notice, here is a blessing:
 **
 **    May you do good and not evil.
 **    May you find forgiveness for yourself and forgive others.
 **    May you share freely, never taking more than you give.
 **/

#pragma once
#ifndef POPEN_PLUS_HPP_f28c53c53a48d38efafee7fb7004a01faaac9e22
#define POPEN_PLUS_HPP_f28c53c53a48d38efafee7fb7004a01faaac9e22
namespace CG3_PopenPlus {

#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <paths.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>

#define READ 0
#define WRITE 1

typedef struct {
    pthread_mutex_t mutex;
    pid_t pid;
    FILE *read_fp;
    FILE *write_fp;
} popen_plus_process;

popen_plus_process *popen_plus(const char *command);
int popen_plus_close(popen_plus_process *process);
int popen_plus_kill(popen_plus_process *process);
int popen_plus_kill_by_id(int process_id);
int popen_plus_terminate(popen_plus_process *process);
int popen_plus_terminate_with_id(int process_id);

}
using namespace CG3_PopenPlus;
#endif