updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / lxdm-svn / 20-stderr_stdout_to_log.patch
blobef02851b58a7e56a59c01eb3528382817f7df05f
1 Index: lxdm-svn/src/lxdm.c
2 ===================================================================
3 --- lxdm-svn/src/lxdm.c (revision 2334)
4 +++ lxdm-svn/src/lxdm.c (working copy)
5 @@ -212,6 +212,15 @@
6 exit(0);
9 +void log_clear(void)
11 + FILE *log;
12 + log=fopen("/var/log/lxdm.log","w");
13 + if(!log)
14 + return;
15 + fclose(log);
18 void log_print(char *fmt, ...)
20 static FILE *log;
21 @@ -229,6 +238,11 @@
22 if( !log )
23 return;
25 + fclose(log);
26 + log=freopen("/var/log/lxdm.log","a",stdout);
27 + setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
28 + freopen("/var/log/lxdm.log","a",stderr);
29 + setvbuf(stderr, NULL, _IONBF, BUFSIZ);
30 va_start(ap, fmt);
31 vfprintf(log, fmt, ap);
32 va_end(ap);
33 @@ -594,6 +608,7 @@
34 if( !getenv("DISPLAY") )
35 putenv("DISPLAY=:0");
37 + log_print("%s\n","start X");
38 create_server_auth();
40 arg = g_key_file_get_string(config, "server", "arg", 0);
41 @@ -607,6 +622,8 @@
43 case 0:
44 setpgid( 0, getpid() );
45 + // required to catch output
46 + log_print("%s\n", "lxdm forked");
47 execvp(args[0], args);
48 break;
49 case -1:
50 @@ -1040,6 +1057,7 @@
52 set_signal();
53 lxdm_get_tty();
54 + log_clear();
55 startx();
57 for( tmp = 0; tmp < 200; tmp++ )