server.c
author Lluís Batlle <viric@viric.name>
Thu, 20 Mar 2014 16:33:27 +0100
changeset 97 eea77d5a624c
parent 95 13360d8af313
permissions -rw-r--r--
Merging the savefile branch. I hope it works; I even don't remember it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     1
/*
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     2
    Terminal Mixer - multi-point multi-user access to terminal applications
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     3
    Copyright (C) 2007  LluĂ­s Batlle i Rossell
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     4
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     5
    Please find the license in the provided COPYING file.
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     6
*/
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
     7
#include <stdio.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
     8
#include <stdlib.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
     9
#include <sys/types.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    10
#include <sys/select.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    11
#include <unistd.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    12
#include <errno.h>
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    13
#include <signal.h>
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    14
#include <string.h>
94
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
    15
#include <fcntl.h>
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    16
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    17
#include "main.h"
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    18
#include "handlers.h"
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    19
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    20
/* signals.c */
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    21
extern int child_died;
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    22
94
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
    23
/* app_control.c */
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
    24
extern int savefile;
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
    25
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    26
/*extern*/
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    27
void fdset_dump(fd_set *set, int maxfd);
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    28
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    29
static void loop()
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    30
{
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    31
    fd_set read_set;
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    32
    sigset_t sigempty,signoalarm;
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    33
    int maxfd;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    34
    int stdin_opened;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    35
    int res;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    36
41
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
    37
    if (command_line.s_param.nohup)
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
    38
        stdin_opened = 0;
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
    39
    else
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
    40
        stdin_opened = 1;
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
    41
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    42
    /* Prepare the sigset for blocking alarm */
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    43
    sigemptyset(&signoalarm);
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    44
    sigaddset(&signoalarm, SIGALRM);
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    45
    sigemptyset(&sigempty);
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    46
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    47
    do
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    48
    {
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    49
        FD_ZERO(&read_set);
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    50
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    51
        maxfd = -1;
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    52
        if (stdin_opened)
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    53
        {
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    54
            FD_SET(0, &read_set);
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    55
            maxfd = 0;
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    56
        }
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    57
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    58
        app_control_prepare_read_fdset(&read_set, &maxfd);
33
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
    59
        if (command_line.s_param.serve_unix)
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
    60
            s_unix_prepare_read_fdset(&read_set, &maxfd);
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
    61
        if (command_line.s_param.serve_tcp)
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
    62
            s_tcp_prepare_read_fdset(&read_set, &maxfd);
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
    63
#ifdef linux
44
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
    64
        if (command_line.s_param.serve_eth)
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
    65
            s_eth_prepare_read_fdset(&read_set, &maxfd);
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
    66
#endif /* linux */
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    67
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    68
        /* Prepare checking for timeout */
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    69
        sigprocmask(SIG_BLOCK, &signoalarm, 0);
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    70
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    71
#ifdef linux
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    72
        if (command_line.s_param.serve_eth)
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    73
            /* This will check if the timeout occurred,
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    74
             * and will not do anything otherwise. */
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    75
            eth_proto_process_timeouts();
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    76
#endif
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    77
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    78
        if (maxfd == -1)
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    79
          error("No fds in select");
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    80
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    81
        debugmsg("Blocking in pselect");
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    82
        if (child_died == 1)
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    83
          break;
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
    84
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    85
        /* Will block */
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    86
        res = pselect(maxfd + 1, &read_set, 0, 0, 0, &sigempty);
66
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 53
diff changeset
    87
#ifdef linux
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 53
diff changeset
    88
        if (command_line.s_param.serve_eth)
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 53
diff changeset
    89
            eth_proto_process_timeouts();
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 53
diff changeset
    90
#endif
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    91
        if (res == -1)
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    92
        {
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    93
            if (errno == EINTR)
84
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 82
diff changeset
    94
            {
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 82
diff changeset
    95
                dump_line("Signal received in server select()\n");
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    96
                continue;
84
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 82
diff changeset
    97
            }
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    98
            else
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    99
                error("Error in select()");
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   100
        }
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   101
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   102
        res = app_control_process_read_fdset(&read_set);
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   103
        if (res == -1) /* app_stdout and app_stderr closed */
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   104
            break;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   105
41
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   106
        if (stdin_opened && FD_ISSET(0, &read_set))
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   107
        {
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   108
            res = read(0, stream_buffer, stream_buffer_size);
32
df110f784648 Added read-only clients, added stdin-close option to clients.
lbatlle@npdl268.bpo.hp.com
parents: 29
diff changeset
   109
            /* if res is 0, the fcall will close app_stdin */
df110f784648 Added read-only clients, added stdin-close option to clients.
lbatlle@npdl268.bpo.hp.com
parents: 29
diff changeset
   110
            app_control_local_send_to_stdin(stream_buffer, res);
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   111
            if (res == 0)
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
   112
            {
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
   113
                debugmsg("Closing stdin\n");
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   114
                stdin_opened = 0;
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 71
diff changeset
   115
            }
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   116
        }
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   117
33
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
   118
        if (command_line.s_param.serve_unix)
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
   119
            s_unix_process_read_fdset(&read_set);
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
   120
        if (command_line.s_param.serve_tcp)
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
   121
            s_tcp_process_read_fdset(&read_set);
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
   122
#ifdef linux
44
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   123
        if (command_line.s_param.serve_eth)
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   124
            s_eth_process_read_fdset(&read_set);
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
   125
#endif /* linux */
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   126
    } while(1);
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   127
}
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   128
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   129
int server()
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   130
{
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   131
    int child;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   132
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   133
    command_line.is_server = 1;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   134
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 33
diff changeset
   135
    app_control_start();
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 33
diff changeset
   136
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   137
    /* in raw mode, the signals for Control-C, ... will be generated by the
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   138
     * slave pty. The master will receive the key codes. */
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   139
    if (command_line.s_param.serve_unix)
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   140
        s_unix_update_served(command_line.s_param.max_served);
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   141
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   142
    if (command_line.s_param.serve_tcp)
33
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
   143
        s_tcp_update_served(command_line.s_param.max_served);
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   144
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
   145
#ifdef linux
44
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   146
    if (command_line.s_param.serve_eth)
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   147
        s_eth_init();
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
   148
#endif /* linux */
44
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   149
94
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
   150
    if (command_line.s_param.savefile)
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
   151
    {
95
13360d8af313 Fixing a problem on savefile (stdin was not saved well, and the file not
viric <viriketo@gmail.com>
parents: 94
diff changeset
   152
        savefile = open(command_line.s_param.savefile,
13360d8af313 Fixing a problem on savefile (stdin was not saved well, and the file not
viric <viriketo@gmail.com>
parents: 94
diff changeset
   153
                O_CREAT | O_TRUNC | O_RDWR, 0666);
94
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
   154
    }
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 86
diff changeset
   155
40
da3ea7f666e3 Fixed env vars and paths for the unix socket.
viric@llimona
parents: 36
diff changeset
   156
    child = fork_app(command_line.s_param.command);
da3ea7f666e3 Fixed env vars and paths for the unix socket.
viric@llimona
parents: 36
diff changeset
   157
41
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   158
    if (command_line.s_param.nohup)
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   159
    {
71
c209487034d7 True nohup-like behaviour. Programs ignore to SIGHUP.
viric@llimona
parents: 67
diff changeset
   160
        ignore_sighup();
41
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   161
        close(0);
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   162
        close(1);
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   163
        close(2);
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   164
    } else
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   165
        if (command_line.s_param.run_in_subterminal)
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   166
            prepare_user_terminal();
40
da3ea7f666e3 Fixed env vars and paths for the unix socket.
viric@llimona
parents: 36
diff changeset
   167
da3ea7f666e3 Fixed env vars and paths for the unix socket.
viric@llimona
parents: 36
diff changeset
   168
    install_signal_forwarders(child);
da3ea7f666e3 Fixed env vars and paths for the unix socket.
viric@llimona
parents: 36
diff changeset
   169
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   170
    loop();
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   171
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   172
    if (command_line.s_param.serve_unix)
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   173
        s_unix_shutdown();
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   174
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   175
    if (command_line.s_param.serve_tcp)
33
010af11f521e Raw implementation for tcp.
lbatlle@npdl268.bpo.hp.com
parents: 32
diff changeset
   176
        s_tcp_shutdown();
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   177
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
   178
#ifdef linux
44
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   179
    if (command_line.s_param.serve_eth)
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   180
        s_eth_shutdown();
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 44
diff changeset
   181
#endif /* linux */
44
41241a0f84bf Almost fixed eth transport.
viric@llimona
parents: 41
diff changeset
   182
41
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   183
    if (!command_line.s_param.nohup &&
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 40
diff changeset
   184
            command_line.s_param.run_in_subterminal)
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   185
        restore_user_terminal();
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   186
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   187
    return 0;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   188
}