2

Iam trying to implement git cherrypicking.

My process hangs when I close the merge tool without solving mergeconflicts, since airaxis tool asks for Was the merge successful? [y/n].

How do I check if my process is waiting for input?
How can I read the message?

I would like to fetch the output before the process has exited.

Can you please help.

Here is my code.

   member this.ProcessOutputDataReceived(e : DataReceivedEventArgs) =
   if not(String.IsNullOrWhiteSpace(e.Data)) then
        this.output <- this.output @ [e.Data]
        System.Diagnostics.Debug.WriteLine(e.Data)
    ()

    member this.ExecuteCommandWait(program, args, wd) =
        this.Program <- program
        let startInfo = ProcessStartInfo(FileName = program,
                                         Arguments = args,
                                         CreateNoWindow = true,
                                         UseShellExecute = false,
                                         RedirectStandardOutput = true,
                                         RedirectStandardError = true,
                                         RedirectStandardInput = true,
                                         WindowStyle = ProcessWindowStyle.Hidden,
                                         WorkingDirectory = wd)
        this.proc <- new Process(StartInfo = startInfo)
        this.proc.ErrorDataReceived.Add(this.ProcessErrorDataReceived)
        this.proc.OutputDataReceived.Add(this.ProcessOutputDataReceived)
        this.proc.Start()
        this.proc.BeginOutputReadLine()
        this.proc.BeginErrorReadLine()
        this.proc.WaitForExit()
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
bhavani
  • 29
  • 3
  • git commands that iam using "git cherrypick commit", if conflict found then – bhavani May 23 '16 at 13:01
  • git mergetool -t araxis, at this point new araxis tool popsup and the process is waiting to exit, if I close the the tool without solving conflicts, it asks the user for input. How can I read the question that the git is asking or how do I know if the process is waiting for input. – bhavani May 23 '16 at 13:05
  • 1
    @FoggyFinder I think they view it as `My code is broke, help me debug it` and didn't show any work on what they did to resolve it. I considered a close vote but since the OP is new I just moved on; no close vote, no down vote. The OP should provide what they researched and didn't work. I have worked with ProcessStartInfo with F# but think the OP's problem is not with F# but with using ProcessStartInfo in general. – Guy Coder May 23 '16 at 15:30
  • 2
    Realistically, if you are scripting, there are a different set of git commands, it is much easier to use these. – John Palmer May 23 '16 at 22:16
  • Well, I have tried by setting time out to the process, and kill the process if has not exited. That is how I know that its waiting for input, I have tried also by using thread event, that didn't help.Thanks, I will try with diff git commands. – bhavani May 24 '16 at 03:35
  • I haven't worked with ProcessStartInfo in a while, but I think you need something that turns the writing to the output device into an event notification, thus: [Process.OutputDataReceived Event](https://msdn.microsoft.com/en-us/library/system.diagnostics.process.outputdatareceived(v=vs.110).aspx) – Guy Coder May 26 '16 at 12:58
  • Of interest: [Capturing process output via OutputDataReceived event](http://stackoverflow.com/questions/11631443/capturing-process-output-via-outputdatareceived-event) – Guy Coder May 26 '16 at 13:22
  • Of interest: [Google: .net process capture output to event](https://www.google.com/search?q=processeventargs&ie=&oe=#q=.net+process+capture+output+to+event) – Guy Coder May 26 '16 at 13:24

0 Answers0