Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ce862ac in mainline


Ignore:
Timestamp:
2021-11-02T18:49:52Z (4 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
b48e680f
Parents:
24c452b3
Message:

Terminate terminal if the child task has terminated

Try saying that three times quickly.

Location:
uspace/app/terminal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/terminal/main.c

    r24c452b3 rce862ac  
    3333 */
    3434
     35#include <ui/ui.h>
    3536#include <stdio.h>
    36 #include <task.h>
    37 #include <ui/ui.h>
    3837#include "terminal.h"
    3938
     
    9897                return 1;
    9998
    100         task_retval(0);
    101         async_manager();
     99        ui_run(terminal->ui);
     100
     101        terminal_destroy(terminal);
    102102        return 0;
    103103}
  • uspace/app/terminal/terminal.c

    r24c452b3 rce862ac  
    4141#include <fbfont/font-8x16.h>
    4242#include <io/chargrid.h>
     43#include <fibril.h>
    4344#include <gfx/bitmap.h>
    4445#include <gfx/context.h>
     
    128129};
    129130
     131static errno_t terminal_wait_fibril(void *);
     132
    130133static terminal_t *srv_to_terminal(con_srv_t *srv)
    131134{
     
    133136}
    134137
    135 static void getterm(const char *svc, const char *app)
    136 {
    137         task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
     138static errno_t getterm(task_wait_t *wait, const char *svc, const char *app)
     139{
     140        return task_spawnl(NULL, wait, APP_GETTERM, APP_GETTERM, svc,
    138141            LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
    139142}
     
    804807        terminal_t *term = (terminal_t *) arg;
    805808
    806         (void) term;
    807 
    808         // XXX This is not really a clean way of terminating
    809         exit(0);
     809        ui_quit(term->ui);
    810810}
    811811
     
    10141014
    10151015        list_append(&term->link, &terms);
    1016         getterm(vc, command);
     1016        rc = getterm(&term->wait, vc, command);
     1017        if (rc != EOK)
     1018                goto error;
     1019
     1020        term->wfid = fibril_create(terminal_wait_fibril, term);
     1021        if (term->wfid == 0)
     1022                goto error;
     1023
     1024        fibril_add_ready(term->wfid);
    10171025
    10181026        term->is_focused = true;
     
    10401048}
    10411049
     1050static errno_t terminal_wait_fibril(void *arg)
     1051{
     1052        terminal_t *term = (terminal_t *)arg;
     1053        task_exit_t texit;
     1054        int retval;
     1055
     1056        /*
     1057         * XXX There is no way to break the sleep if the task does not
     1058         * exit.
     1059         */
     1060        (void) task_wait(&term->wait, &texit, &retval);
     1061        ui_quit(term->ui);
     1062        return EOK;
     1063}
     1064
    10421065/** @}
    10431066 */
  • uspace/app/terminal/terminal.h

    r24c452b3 rce862ac  
    3838#define TERMINAL_H
    3939
     40#include <adt/prodcons.h>
    4041#include <errno.h>
     42#include <fibril.h>
    4143#include <fibril_synch.h>
    4244#include <gfx/bitmap.h>
     
    4648#include <io/con_srv.h>
    4749#include <loc.h>
    48 #include <adt/prodcons.h>
    4950#include <stdatomic.h>
    5051#include <str.h>
     52#include <task.h>
    5153#include <ui/ui.h>
    5254#include <ui/window.h>
     
    9193        service_id_t dsid;
    9294        con_srvs_t srvs;
     95
     96        task_wait_t wait;
     97        fid_t wfid;
    9398} terminal_t;
    9499
Note: See TracChangeset for help on using the changeset viewer.