~ubuntu-branches/ubuntu/oneiric/valkyrie/oneiric

« back to all changes in this revision

Viewing changes to valkyrie/tool_utils/async_process.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2011-09-02 22:08:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: package-import@ubuntu.com-20110902220834-kigsixteppj9epp5
Tags: 2.0.0-0ubuntu1
* New upstream release. (LP: #635129, LP: #832886, LP: #721298)
* Standards bumped to 3.9.2, no changes required.
* d/control, d/rules: cdbs removed, dh minimal rule instead.
* d/control: build system is qmake not autotools
* d/control: bump required qt to qt4
* d/valkyrie.install: installing html docs manually as make install
  no longer does so.
* d/patches/valkyrie-2.0.0-fix-doc.dir.patch: Fix doc path to match
  policy. Also corrects LP: #588074 since the documentation link now
  works.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ---------------------------------------------------------------------
2
 
 * Definition of class AsyncProcess                      async_process.h
3
 
 *
4
 
 * Contains various bits and pieces ripped off from all over the
5
 
 * place.  No credit to me, all credit to the various authors.
6
 
 *
7
 
 * Process Launching
8
 
 * Executes a child program asynchronously (main program won't block
9
 
 * waiting for the child to exit).
10
 
 *
11
 
 * The first string in arglist (ie. arglist[0]) is the name of the
12
 
 * program to execute. By default, the name of the program must be a
13
 
 * full path; the PATH shell variable will only be searched if you
14
 
 * pass the SEARCH_PATH flag.
15
 
 * --------------------------------------------------------------------- 
16
 
 * This file is part of Valkyrie, a front-end for Valgrind
17
 
 * Copyright (C) 2000-2008, OpenWorks LLP <info@open-works.co.uk>
18
 
 * This program is released under the terms of the GNU GPL v.2
19
 
 * See the file COPYING for the full license details.
20
 
 */
21
 
 
22
 
#ifndef __VK_ASYNC_PROCESS_H
23
 
#define __VK_ASYNC_PROCESS_H
24
 
 
25
 
 
26
 
#include <qstringlist.h>
27
 
 
28
 
 
29
 
class AsyncProcess
30
 
{
31
 
public:
32
 
   enum AsyncFlags { 
33
 
      LEAVE_FDS_OPEN  = 1 << 0, 
34
 
      DONT_REAP_CHILD = 1 << 1,
35
 
      SEARCH_PATH     = 1 << 2 
36
 
   };
37
 
 
38
 
   AsyncProcess( QStringList arglist, AsyncFlags flags );
39
 
   static bool spawn( QStringList arglist, AsyncFlags flags );
40
 
 
41
 
   int  closeAndInvalidate( int* fd );
42
 
 
43
 
   bool makePipe( int p[2] );
44
 
   bool midChild() { return intermediateChild; }
45
 
   bool writeAll( int fd, const void* vbuf, unsigned int to_write );
46
 
 
47
 
   void doExec( int child_err_report_fd );
48
 
 
49
 
private:
50
 
   int  execute();
51
 
   int  saneDup2( int fd1, int fd2 );
52
 
 
53
 
   bool readInts( int fd, int* buf, int n_ints_in_buf, int* n_ints_read );
54
 
 
55
 
   void writeErrAndExit( int fd, int msg );
56
 
   void setCloexec( int fd );
57
 
   void scriptExecute( const char* file, char** argv );
58
 
 
59
 
   char* vkStrchrnul( const char* str, char c );
60
 
 
61
 
private:
62
 
   enum { CHILD_EXEC_FAILED, CHILD_DUP2_FAILED, CHILD_FORK_FAILED };
63
 
 
64
 
   bool searchPath;
65
 
   bool closeDescriptors;
66
 
   bool intermediateChild;
67
 
 
68
 
   QStringList args;
69
 
};
70
 
 
71
 
 
72
 
#endif