~ubuntu-branches/ubuntu/precise/xdm/precise

« back to all changes in this revision

Viewing changes to server.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2008-10-05 20:55:43 UTC
  • mfrom: (7.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081005205543-t9lgih96kbj1eidd
Tags: 1:1.1.8-5
Updated Polish debconf translation, thanks to Łukasz Paździora
(closes: #499073).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XdotOrg: $ */
1
2
/* $Xorg: server.c,v 1.5 2001/02/09 02:05:40 xorgcvs Exp $ */
2
3
/*
3
4
 
48
49
 
49
50
static int receivedUsr1;
50
51
 
51
 
static int serverPause (unsigned t, int serverPid);
52
 
 
53
 
static Display  *dpy;
 
52
static int serverPause (unsigned t, pid_t serverPid);
54
53
 
55
54
/* ARGSUSED */
56
55
static SIGVAL
78
77
    char        **f;
79
78
    char        **argv;
80
79
    char        arg[1024];
81
 
    int         pid;
 
80
    pid_t       pid;
82
81
 
83
82
    Debug ("StartServer for %s\n", d->name);
84
83
    receivedUsr1 = 0;
169
168
}
170
169
 
171
170
static int
172
 
serverPause (unsigned t, int serverPid)
 
171
serverPause (unsigned t, pid_t serverPid)
173
172
{
174
 
    int         pid;
 
173
    pid_t       pid;
175
174
 
176
175
    serverPauseRet = 0;
177
176
    if (!Setjmp (pauseAbort)) {
189
188
            Debug ("Already received USR1\n");
190
189
#endif
191
190
        for (;;) {
192
 
#if defined(SYSV) && defined(X_NOT_POSIX)
193
191
            /*
194
192
             * wait() is unsafe.  Other Xserver or xdm processes may
195
193
             * exit at this time and this will remove the wait status.
196
194
             * This means the main loop will not restart the display.
197
195
             */
198
 
            pid = wait ((waitType *) 0);
199
 
#else
200
196
            if (!receivedUsr1)
201
 
#ifndef X_NOT_POSIX
202
197
                pid = waitpid (serverPid, (int *) 0, 0);
203
198
            else
204
199
                pid = waitpid (serverPid, (int *) 0, WNOHANG);
205
 
#else
206
 
            /*
207
 
             * If you have wait4() but not waitpid(), use that instead
208
 
             * of wait() and wait3() to make this code safe.  See
209
 
             * above comment.
210
 
             */
211
 
                pid = wait ((waitType *) 0);
212
 
            else
213
 
                pid = wait3 ((waitType *) 0, WNOHANG,
214
 
                             (struct rusage *) 0);
215
 
#endif /* X_NOT_POSIX */
216
 
#endif /* SYSV */
 
200
 
217
201
            if (pid == serverPid ||
218
202
               (pid == -1 && errno == ECHILD))
219
203
            {
221
205
                serverPauseRet = 1;
222
206
                break;
223
207
            }
224
 
#if !defined(SYSV) || !defined(X_NOT_POSIX)
 
208
 
225
209
            if (pid == 0) {
226
210
                Debug ("Server alive and kicking\n");
227
211
                break;
228
212
            }
229
 
#endif
230
213
        }
231
214
    }
232
215
    (void) alarm ((unsigned) 0);
319
302
            Debug ("Before XOpenDisplay(%s)\n", d->name);
320
303
            errno = 0;
321
304
            (void) XSetIOErrorHandler (openErrorHandler);
322
 
            dpy = XOpenDisplay (d->name);
 
305
            d->dpy = XOpenDisplay (d->name);
323
306
#ifdef STREAMSCONN
324
307
            {
325
308
                /* For some reason, the next XOpenDisplay we do is
335
318
            (void) Signal (SIGALRM, SIG_DFL);
336
319
            (void) XSetIOErrorHandler ((int (*)(Display *)) 0);
337
320
            Debug ("After XOpenDisplay(%s)\n", d->name);
338
 
            if (dpy) {
 
321
            if (d->dpy) {
339
322
#ifdef XDMCP
340
323
                if (d->displayType.location == Foreign)
341
 
                    GetRemoteAddress (d, ConnectionNumber (dpy));
 
324
                    GetRemoteAddress (d, ConnectionNumber (d->dpy));
342
325
#endif
343
 
                RegisterCloseOnFork (ConnectionNumber (dpy));
344
 
                (void) fcntl (ConnectionNumber (dpy), F_SETFD, 0);
 
326
                RegisterCloseOnFork (ConnectionNumber (d->dpy));
 
327
                (void) fcntl (ConnectionNumber (d->dpy), F_SETFD, 0);
345
328
                return 1;
346
329
            } else {
347
330
                Debug ("OpenDisplay failed %d (%s) on \"%s\"\n",
364
347
void
365
348
ResetServer (struct display *d)
366
349
{
367
 
    if (dpy && d->displayType.origin != FromXDMCP)
368
 
        pseudoReset (dpy);
 
350
    if (d->dpy && d->displayType.origin != FromXDMCP)
 
351
        pseudoReset (d->dpy);
369
352
}
370
353
 
371
354
static Jmp_buf  pingTime;
399
382
    int     oldAlarm;
400
383
    static Display *aDpy;
401
384
    
402
 
    aDpy = (alternateDpy != NULL ? alternateDpy : dpy);
 
385
    aDpy = (alternateDpy != NULL ? alternateDpy : d->dpy);
403
386
    oldError = XSetIOErrorHandler (PingLostIOErr);
404
387
    oldAlarm = alarm (0);
405
388
    oldSig = Signal (SIGALRM, PingLostSig);