unit DosCommandHandle;

interface

uses
  Windows, Classes, Rubies, DosCommand;

type
  TDosCommandHandle = class(TObject)
  public
    procedure doTerminate(Sender: TObject);
  end;

var
  Handle: TDosCommandHandle;

implementation

uses Pythia;

{ TDosCommandHandle }

procedure TDosCommandHandle.doTerminate(Sender: TObject);
var
  recv: Tvalue;
  data: Tvalue;
begin
  if not  (Sender is TDosThread) then exit;
  recv := (Sender as TDosThread).owner.tag;  // !!!
  if recv = 0 then Exit;
  data := rb_ary_new;
  rb_ary_push(data, rb_intern('on_terminate'));
  rb_ary_push(data, recv);
  PhiCallProtect(data);
end;

initialization
  Handle := TDosCommandHandle.Create;
finalization
  Handle.Free;
end.
