File: process.h

package info (click to toggle)
falconpl 0.9.6.9-git20120606-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 46,176 kB
  • sloc: cpp: 181,389; ansic: 109,025; yacc: 2,310; xml: 1,218; sh: 403; objc: 245; makefile: 82; sql: 20
file content (99 lines) | stat: -rw-r--r-- 2,250 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
   FALCON - The Falcon Programming Language.
   FILE: process_sys.h

   System dependent module specifications for process module
   -------------------------------------------------------------------
   Author: Giancarlo Niccolai
   Begin: sab mar 11 2006

   -------------------------------------------------------------------
   (C) Copyright 2004: the FALCON developers (see list in AUTHORS file)

   See LICENSE file for licensing details.
*/

/** \file
   System dependent module specifications for process module
*/

#ifndef flc_process_sys_H
#define flc_process_sys_H

#include <falcon/stream.h>
#include <falcon/string.h>

namespace Falcon { namespace Sys {



class Process
{
   bool m_done;
   int m_lastError;
   int m_procVal;

public:
   Process():
       m_done(false),
       m_lastError( 0 ),
       m_procVal( 0 )
   {}
   virtual ~Process() { }

   /*
    * Interface
    */
   virtual Falcon::Stream* inputStream() = 0;
   virtual Falcon::Stream* outputStream() = 0;
   virtual Falcon::Stream* errorStream() = 0;
   //
   virtual bool close() = 0;
   virtual bool wait( bool block ) = 0 ;
   virtual bool terminate( bool severe = false ) = 0;


   int processValue() const { return m_procVal; }
   void processValue( int val ) { m_procVal = val; }
   bool done() const { return m_done; }
   void done( bool d ) { m_done = d; }
   int lastError() const { return m_lastError; }
   void lastError( int val ) { m_lastError = val; }

   static Process* factory();
};



class ProcessEnum
{
   void *m_sysdata;

public:
   ProcessEnum();
   virtual ~ProcessEnum();

   /** Get next entry in the enum.
      \return -1 on error, 0 on done, 1 on next available.
   */
   int next( String &name, uint64 &pid, uint64 &ppid, String &path );
   bool close();
};

bool spawn( String **args, bool overlay, bool background, int *result );
bool spawn_read( String **args, bool overlay, bool background, int *result, String *sOut );

const char *shellParam();
const char *shellName();
bool openProcess(Process* ph, String **args, bool sinkin, bool sinkout, bool sinkerr, bool mergeErr, bool bg );

uint64 processId();
bool processKill( uint64 id );
bool processTerminate( uint64 id );


}} // ns Falcon::Sys

#endif

/* end of process_sys.h */