[Wine-patches] [eterhack] Fix a problem with services and wineole.

Alexander Morozov amorozov на etersoft.ru
Ср Дек 23 15:59:58 MSK 2009


----------- следующая часть -----------
From ce55c3212e072c8896e8ac29a2592e89e8c83a76 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 23 Dec 2009 15:54:35 +0300
Subject: [eterhack] Fix a problem with services and wineole.

---
 etersoft/scripts/wine.in     |   11 ++++++++++-
 programs/wineboot/wineboot.c |   19 ++++++++++++-------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/etersoft/scripts/wine.in b/etersoft/scripts/wine.in
index 73d9736..d7b5f57 100644
--- a/etersoft/scripts/wine.in
+++ b/etersoft/scripts/wine.in
@@ -28,6 +28,9 @@ test -f $WINEPREFIX/config && . $WINEPREFIX/config
 
 [ -z "$WINELOADER" ] && export WINELOADER=$BINDIR/wine-glibc
 
+saved_WINEDLLOVERRIDES="$WINEDLLOVERRIDES"
+unset WINEDLLOVERRIDES
+
 # missed on FreeBSD
 [ -z "$UID" ] && export UID=`id -u`
 
@@ -70,12 +73,18 @@ run_wine()
 {
 	# do not check DISPLAY here, console programs can be started without DISPLAY
 	if tty -s ; then
+		$WINELOADER wineboot.exe --only-first
+		export WINEDLLOVERRIDES="$saved_WINEDLLOVERRIDES"
 		exec $WINELOADER "$@"
 	else
 		echo "$0: Running without console, disable input" >&2
 		if false && [ -z "$WINELOGFILO" ] ; then
-			exec $WINELOADER "$@" </dev/null >$WINEPREFIX/wine.log 2>$WINEPREFIX/wine.log
+			$WINELOADER wineboot.exe --only-first </dev/null >$WINEPREFIX/wine.log 2>$WINEPREFIX/wine.log
+			export WINEDLLOVERRIDES="$saved_WINEDLLOVERRIDES"
+			exec $WINELOADER "$@" </dev/null >>$WINEPREFIX/wine.log 2>>$WINEPREFIX/wine.log
 		else
+			$WINELOADER wineboot.exe --only-first </dev/null
+			export WINEDLLOVERRIDES="$saved_WINEDLLOVERRIDES"
 			exec $WINELOADER "$@" </dev/null
 		fi
 	fi
diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index 6a8ed81..9bae27e 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -918,12 +918,13 @@ static void usage(void)
     WINE_MESSAGE( "    -f,--force        Force exit for processes that don't exit cleanly\n" );
     WINE_MESSAGE( "    -i,--init         Perform initialization for first Wine instance\n" );
     WINE_MESSAGE( "    -k,--kill         Kill running processes without any cleanup\n" );
+    WINE_MESSAGE( "    -o,--only-first   Do not run if it is started already\n");
     WINE_MESSAGE( "    -r,--restart      Restart only, don't do normal startup operations\n" );
     WINE_MESSAGE( "    -s,--shutdown     Shutdown only, don't reboot\n" );
     WINE_MESSAGE( "    -u,--update       Update the wineprefix directory\n" );
 }
 
-static const char short_options[] = "efhikrsu";
+static const char short_options[] = "efhikorsu";
 
 static const struct option long_options[] =
 {
@@ -932,6 +933,7 @@ static const struct option long_options[] =
     { "force",       0, 0, 'f' },
     { "init" ,       0, 0, 'i' },
     { "kill",        0, 0, 'k' },
+    { "only-first",  0, 0, 'o' },
     { "restart",     0, 0, 'r' },
     { "shutdown",    0, 0, 's' },
     { "update",      0, 0, 'u' },
@@ -945,7 +947,7 @@ int main( int argc, char *argv[] )
 
     /* First, set the current directory to SystemRoot */
     int optc;
-    int end_session = 0, force = 0, init = 0, kill = 0, restart = 0, shutdown = 0, update = 0;
+    int end_session = 0, force = 0, init = 0, kill = 0, restart = 0, shutdown = 0, update = 0, only_first = 0;
     HANDLE event;
     SECURITY_ATTRIBUTES sa;
 
@@ -961,6 +963,7 @@ int main( int argc, char *argv[] )
         case 'f': force = 1; break;
         case 'i': init = 1; break;
         case 'k': kill = 1; break;
+        case 'o': only_first = 1; break;
         case 'r': restart = 1; break;
         case 's': shutdown = 1; break;
         case 'u': update = 1; break;
@@ -969,6 +972,13 @@ int main( int argc, char *argv[] )
         }
     }
 
+    sa.nLength = sizeof(sa);
+    sa.lpSecurityDescriptor = NULL;
+    sa.bInheritHandle = TRUE;  /* so that services.exe inherits it */
+    event = CreateEventW( &sa, TRUE, FALSE, wineboot_eventW );
+
+    if (only_first && GetLastError() == ERROR_ALREADY_EXISTS) return 0;
+
     if (end_session)
     {
         if (!shutdown_close_windows( force )) return 1;
@@ -978,11 +988,6 @@ int main( int argc, char *argv[] )
 
     if (shutdown) return 0;
 
-    sa.nLength = sizeof(sa);
-    sa.lpSecurityDescriptor = NULL;
-    sa.bInheritHandle = TRUE;  /* so that services.exe inherits it */
-    event = CreateEventW( &sa, TRUE, FALSE, wineboot_eventW );
-
     ResetEvent( event );  /* in case this is a restart */
 
     create_hardware_registry_keys();
-- 
1.6.5.6



Подробная информация о списке рассылки Wine-patches