Skip to content

Commit 1a9cefc

Browse files
On Mono, it's easier to invoke rabbitmqctl directly
Propagating command line arguments is fragile and brings no benefits.
1 parent bf0682e commit 1a9cefc

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

projects/client/Unit/src/unit/TestConnectionBlocked.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,32 +101,31 @@ protected void Unblock()
101101
ExecRabbitMQCtl("set_vm_memory_high_watermark 0.4");
102102
}
103103

104-
protected void ExecRabbitMQCtl(string command)
104+
protected void ExecRabbitMQCtl(string args)
105105
{
106106
if(IsRunningOnMono()) {
107-
ExecCommand("../rabbitmq-server/scripts/rabbitmqctl " + command);
107+
ExecCommand("../../../../../../rabbitmq-server/scripts/rabbitmqctl", args);
108108
} else {
109-
ExecCommand("..\\rabbitmq-server\\scripts\\rabbitmqctl.bat " + command);
109+
ExecCommand("..\\..\\..\\..\\..\\..\\rabbitmq-server\\scripts\\rabbitmqctl.bat", args);
110110
}
111111
}
112112

113-
protected void ExecCommand(string command)
113+
protected void ExecCommand(string ctl, string args)
114114
{
115115
Process proc = new Process();
116-
proc.StartInfo.CreateNoWindow = true;
116+
proc.StartInfo.CreateNoWindow = true;
117+
proc.StartInfo.UseShellExecute = false;
117118

118-
string sh;
119-
string args;
119+
string cmd;
120120
if(IsRunningOnMono()) {
121-
sh = "/bin/sh";
122-
args = "-c " + command;
121+
cmd = ctl;
123122
} else {
124-
sh = "C:\\winnt\\system32\\cmd.exe";
125-
args = "/y /c " + command;
123+
cmd = "C:\\winnt\\system32\\cmd.exe";
124+
args = "/y /c " + ctl + " " + args;
126125
}
127126

128127
try {
129-
proc.StartInfo.FileName = sh;
128+
proc.StartInfo.FileName = cmd;
130129
proc.StartInfo.Arguments = args;
131130

132131
proc.Start();

0 commit comments

Comments
 (0)