- exitstatus = execute ("mcs", "mcs", argv, false, false, true, true, true,
- false);
- mcs_present = (exitstatus == 0);
+ child = create_pipe_in ("mcs", "mcs", argv, DEV_NULL, true, true, false,
+ fd);
+ mcs_present = false;
+ if (child != -1)
+ {
+ /* Read the subprocess output, and test whether it contains the
+ string "Mono". */
+ char c[4];
+ size_t count = 0;
+
+ while (safe_read (fd[0], &c[count], 1) > 0)
+ {
+ count++;
+ if (count == 4)
+ {
+ if (memcmp (c, "Mono", 4) == 0)
+ mcs_present = true;
+ c[0] = c[1]; c[1] = c[2]; c[2] = c[3];
+ count--;
+ }
+ }
+
+ close (fd[0]);
+
+ /* Remove zombie process from process list, and retrieve exit
+ status. */
+ exitstatus =
+ wait_subprocess (child, "mcs", false, true, true, false, NULL);
+ if (exitstatus != 0)
+ mcs_present = false;
+ }