Exemplo n.º 1
0
 private void onProcessExit(ClientProcess cproc)
 {
     Monitor.Enter(this.exitedProcessesLock);
     this.exitedProcesses.Add(cproc);
     this.setProcessingNeeded(true);
     Console.WriteLine(String.Format("Proc with id {0} and filename '{1}' exited.", cproc.Id, cproc.proc_filename));
     Monitor.Exit(this.exitedProcessesLock);
 }
Exemplo n.º 2
0
        private byte[] core_create_proc(byte[] args)
        {
            List <byte> data = new List <byte>(args);

            // first byte indicates if STDIN, STDOUT and STDERR should be streamed to channels
            bool   use_channels  = (Struct.extractByte(data) != 0);
            string proc_filename = Struct.extractNullTerminatedString(data);
            string proc_args     = Struct.extractNullTerminatedString(data);

            ClientProcess proc = new ClientProcess(proc_filename, proc_args, use_channels, this.callbackChannelOutputPresent, this.triggerProcessingNeeded); //starts the process already

            proc.registerOnExitCallback(this.onProcessExit);


            if (use_channels)
            {
                this.AddChannel(proc.Ch_stdin);
                this.AddChannel(proc.Ch_stdout);
                this.AddChannel(proc.Ch_stderr);


                /*
                 * proc.Ch_stdin = this.tl.CreateChannel(Channel.Types.IN, Channel.Encodings.UTF8);
                 * proc.Ch_stdout = this.tl.CreateChannel(Channel.Types.OUT, Channel.Encodings.UTF8);
                 * proc.Ch_stderr = this.tl.CreateChannel(Channel.Types.OUT, Channel.Encodings.UTF8);
                 */
            }



            //generate method response
            List <byte> resp = Struct.packUInt32((UInt32)proc.Id);

            if (use_channels)
            {
                resp = Struct.packByte(1, resp);
                resp = Struct.packUInt32(proc.Ch_stdin.ID, resp);
                resp = Struct.packUInt32(proc.Ch_stdout.ID, resp);
                resp = Struct.packUInt32(proc.Ch_stderr.ID, resp);
            }
            else
            {
                resp = Struct.packByte(0, resp);
                resp = Struct.packUInt32(0, resp);
                resp = Struct.packUInt32(0, resp);
                resp = Struct.packUInt32(0, resp);
            }

            Monitor.Enter(this.pendingClientProcessesLock);
            this.pending_client_processes.Add(proc.Id, proc);
            Monitor.Exit(this.pendingClientProcessesLock);

            //throw new ClientMethodException(String.Format("Not implemented: Trying to start proc '{0}' with args: {1}", proc_filename, proc_args));
            return(resp.ToArray());
        }