Example #1
0
VOID WINAPI
MyHandler(DWORD fdwControl)
{
    if (g_ssh == 0)
    {
        return;
    }

    if (fdwControl == SERVICE_CONTROL_STOP)
    {
        g_service_status.dwCurrentState = SERVICE_STOP_PENDING;
        g_set_term(1);
    }
    else if (fdwControl == SERVICE_CONTROL_PAUSE)
    {
        /* shouldn't happen */
    }
    else if (fdwControl == SERVICE_CONTROL_CONTINUE)
    {
        /* shouldn't happen */
    }
    else if (fdwControl == SERVICE_CONTROL_INTERROGATE)
    {
    }
    else if (fdwControl == SERVICE_CONTROL_SHUTDOWN)
    {
        g_service_status.dwCurrentState = SERVICE_STOP_PENDING;
        g_set_term(1);
    }

    SetServiceStatus(g_ssh, &g_service_status);
}
Example #2
0
static int APP_CC
xrdp_listen_fork(struct xrdp_listen *self, struct trans *server_trans)
{
    int pid;
    struct xrdp_process *process;

    pid = g_fork();

    if (pid == 0)
    {
        /* child */
        /* recreate some main globals */
        xrdp_child_fork();
        /* recreate the process done wait object, not used in fork mode */
        /* close, don't delete this */
        g_close_wait_obj(self->pro_done_event);
        xrdp_listen_create_pro_done(self);
        /* delete listener, child need not listen */
        trans_delete(self->listen_trans);
        self->listen_trans = 0;
        /* new connect instance */
        process = xrdp_process_create(self, 0);
        process->server_trans = server_trans;
        g_process = process;
        xrdp_process_run(0);
        xrdp_process_delete(process);
        /* mark this process to exit */
        g_set_term(1);
        return 0;
    }

    /* parent */
    trans_delete(server_trans);
    return 0;
}