4 * Copyright (C) 1998 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include <sys/syscall.h>
40 #include "wine/library.h"
42 extern int rtkit_make_realtime(pid_t process
, pid_t thread
, int priority
);
44 /* command-line options */
47 timeout_t master_socket_timeout
= 3 * -TICKS_PER_SEC
; /* master socket timeout, default is 3 seconds */
48 const char *server_argv0
;
52 static void usage( FILE *fh
)
54 fprintf(fh
, "Usage: %s [options]\n\n", server_argv0
);
55 fprintf(fh
, "Options:\n");
56 fprintf(fh
, " -d[n], --debug[=n] set debug level to n or +1 if n not specified\n");
57 fprintf(fh
, " -f, --foreground remain in the foreground for debugging\n");
58 fprintf(fh
, " -h, --help display this help message\n");
59 fprintf(fh
, " -k[n], --kill[=n] kill the current wineserver, optionally with signal n\n");
60 fprintf(fh
, " -p[n], --persistent[=n] make server persistent, optionally for n seconds\n");
61 fprintf(fh
, " -v, --version display version information and exit\n");
62 fprintf(fh
, " -w, --wait wait until the current wineserver terminates\n");
66 static void parse_args( int argc
, char *argv
[] )
70 static struct option long_options
[] =
72 {"debug", 2, NULL
, 'd'},
73 {"foreground", 0, NULL
, 'f'},
74 {"help", 0, NULL
, 'h'},
75 {"kill", 2, NULL
, 'k'},
76 {"persistent", 2, NULL
, 'p'},
77 {"version", 0, NULL
, 'v'},
78 {"wait", 0, NULL
, 'w'},
82 server_argv0
= argv
[0];
84 while ((optc
= getopt_long( argc
, argv
, "d::fhk::p::vw", long_options
, NULL
)) != -1)
89 if (optarg
&& isdigit(*optarg
))
90 debug_level
= atoi( optarg
);
102 if (optarg
&& isdigit(*optarg
))
103 ret
= kill_lock_owner( atoi( optarg
) );
105 ret
= kill_lock_owner(-1);
108 if (optarg
&& isdigit(*optarg
))
109 master_socket_timeout
= (timeout_t
)atoi( optarg
) * -TICKS_PER_SEC
;
111 master_socket_timeout
= TIMEOUT_INFINITE
;
114 fprintf( stderr
, "%s\n", wine_get_build_id());
126 static void sigterm_handler( int signum
)
128 exit(1); /* make sure atexit functions get called */
131 int main( int argc
, char *argv
[] )
133 setvbuf( stderr
, NULL
, _IOLBF
, 0 );
134 parse_args( argc
, argv
);
136 /* setup temporary handlers before the real signal initialization is done */
137 signal( SIGPIPE
, SIG_IGN
);
138 signal( SIGHUP
, sigterm_handler
);
139 signal( SIGINT
, sigterm_handler
);
140 signal( SIGQUIT
, sigterm_handler
);
141 signal( SIGTERM
, sigterm_handler
);
142 signal( SIGABRT
, sigterm_handler
);
145 open_master_socket();
147 if (debug_level
) fprintf( stderr
, "wineserver: starting (pid=%ld)\n", (long) getpid() );
151 rtkit_make_realtime(getpid(), syscall( SYS_gettid
), 2);