Skip to content

Terminal should throw an event when a terminal has completed (and is waiting to close) #18376

Closed

Description

@Tyriar

From Dirk Bäumer (@dbaeumer):

an event when a task executed in a terminal has finished (e.g. the terminal process existed)

Activity

  1. added
    terminal
    on Jan 10, 2017
  2. dbaeumer commented on Jan 11, 2017

    @dbaeumer
    Member

    What I actually want to do is the following:

    this.terminalService.createInstance(`Task: ${task.name}`, undefined, ['/C', 'dir'], false);

    dir is an example here and '/C' is currently specific to cmd.exe.

    What I would like to see happening here is that the cmd.exe is started, dir is executed and then cmd.exe terminates. When cmd.exe terminates I would like to get an event.

    Regarding the '/C' option: any change to have this abstracted in the terminal itself. Having that knowledge on the client side is not very nice.

  3. dbaeumer commented on Jan 11, 2017

    @dbaeumer
    Member

    What currently happens is the following:

    • the terminal is started
    • dir is not executed
    • the terminal stays alive
  4. dbaeumer commented on Jan 11, 2017

    @dbaeumer
    Member

    I changed it to
    this.terminalService.createInstance(Task: ${task.name}, 'C:\\WINDOWS\\system32\\cmd.exe', ['/C', this.configuration.command], false); after some debugging but now no terminal shows up at all. I get an exception messageService.ts:126 write EPIPE

  5. Tyriar commented on Jan 11, 2017

    @Tyriar
    ContributorAuthor

    Did you call Terminal.show() immediately after? API terminals are launched in the background. You could try point to C:\\Windows\\sysnative\\cmd.exe and/or use an environment var to find C:\\Windows. Sysnative is a weird symlink thing that points to system32 or syswow64. Try that first and maybe rm -rf node_modules/node-pty node_modules/pty.js and try reinstall deps?

    It would be good to encapsulate the bash and cmd command execution commands inside the TerminalService, however I'm not sure something like that should be exposed in the Terminal API. In general I don't want to encourage using a custom shell/args unless the specific use case calls for it (like tasks).

  6. dbaeumer commented on Jan 11, 2017

    @dbaeumer
    Member

    I got it working passing in true to waitOnExit. My code looks like this now:

    let terminal = this.terminalService.createInstance(`Task: ${task.name}`, 'C:\\WINDOWS\\system32\\cmd.exe', ['/C', this.configuration.command], true);
    this.terminalService.setActiveInstance(terminal);
    this.terminalService.showPanel(false);

    What I actually would like to have is a listener instead of the waitOnExit. But we already discussed this. Any advice on how to improve this?

  7. dbaeumer commented on Jan 11, 2017

    @dbaeumer
    Member

    Regarding:

    It would be good to encapsulate the bash and cmd command execution commands inside the TerminalService, however I'm not sure something like that should be exposed in the Terminal API. In general I don't want to encourage using a custom shell/args unless the specific use case calls for it (like tasks).

    As said we keep the task framework in the core for now. So it would allow us to experiment with some API here before thinking about making it official.

  8. Tyriar commented on Jan 11, 2017

    @Tyriar
    ContributorAuthor

    Dirk Bäumer (@dbaeumer) I guess I'll expose some event on ITerminalInstance exit for now which when used with waitOnExit to allow reuse of the terminal (via another ITerminalInstance call to start up a new process while retaining the old output).

  9. changed the title [-]Terminal API should throw an event when a terminal has completed (and is waiting to close)[/-] [+]Terminal should throw an event when a terminal has completed (and is waiting to close)[/+] on Jan 11, 2017
  10. Tyriar commented on Jan 11, 2017

    @Tyriar
    ContributorAuthor

    I closed this as it's possible internally now via ITerminalInstance.onExit

  11. hilleer commented on Nov 16, 2017

    @hilleer

    Can you help me on how I get the state of the terminal - e.g. it finished running whatever command? I can't find any help in the documentation.

  12. locked and limited conversation to collaborators on Nov 17, 2017
  13. added a commit that references this issue on Sep 6, 2026
    87a47b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

terminal

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions