This repository has been archived by the owner on Dec 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Job.cs
executable file
·88 lines (74 loc) · 1.58 KB
/
Job.cs
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
/*
* Job.cs
*
* Authors:
* Rolf Bjarne Kvinge (RKvinge@novell.com)
*
* Copyright 2009 Novell, Inc. (http://www.novell.com)
*
* See the LICENSE file included with the distribution for details.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Text;
namespace MonkeyWrench
{
/*
* This class is a wrapper around a process with one difference: it's able to kill itself and all its descendants (like the win32 job object).
*/
public class Job : IDisposable
{
protected Process p = new Process ();
public ProcessStartInfo StartInfo
{
get { return p.StartInfo; }
}
public int ExitCode
{
get { return p.ExitCode; }
}
public bool HasExited
{
get { return p.HasExited; }
}
/// <summary>
/// Terminate this job and all the processes within.
/// </summary>
public virtual void Terminate (SynchronizedStreamWriter logstream)
{
p.KillTree (logstream);
}
/// <summary>
/// Start this job.
/// </summary>
public virtual void Start ()
{
p.Start ();
}
public bool WaitForExit (int milliseconds)
{
return p.WaitForExit (milliseconds);
}
public StreamReader StandardError
{
get { return p.StandardError; }
}
public StreamReader StandardOutput
{
get { return p.StandardOutput; }
}
public StreamWriter StandardInput
{
get { return p.StandardInput; }
}
#region IDisposable Members
public virtual void Dispose ()
{
p.Dispose ();
}
#endregion
}
}