wineserver.pid

Andreas Mohr a.mohr at mailto.de
Thu Aug 9 18:25:26 CDT 2001


Hi all,

some guy was running several different versions of wineservers for one
account via wrapper scripts.
And of course he had a hell of a hard time figuring out which wineserver to
kill for which application ;-)

- announce wineserver's pid in ~/.wine/wineserver-<hostname>/wineserver.pid

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: server/main.c
===================================================================
RCS file: /home/wine/wine/server/main.c,v
retrieving revision 1.21
diff -u -r1.21 main.c
--- server/main.c	21 Mar 2001 20:31:26 -0000	1.21
+++ server/main.c	9 Aug 2001 21:21:57 -0000
@@ -99,6 +99,7 @@
 {
     parse_args( argc, argv );
     signal_init();
+    open_pid_file();
     open_master_socket();
     setvbuf( stderr, NULL, _IOLBF, 0 );
 
Index: server/process.c
===================================================================
RCS file: /home/wine/wine/server/process.c,v
retrieving revision 1.70
diff -u -r1.70 process.c
--- server/process.c	14 Jul 2001 00:50:30 -0000	1.70
+++ server/process.c	9 Aug 2001 21:21:58 -0000
@@ -442,7 +442,11 @@
         /* last process died, close global handles */
         close_global_handles();
         /* this will cause the select loop to terminate */
-        if (!persistent_server) close_master_socket();
+        if (!persistent_server)
+	{
+	    close_master_socket();
+	    close_pid_file();
+	}
     }
 }
 
Index: server/request.c
===================================================================
RCS file: /home/wine/wine/server/request.c,v
retrieving revision 1.54
diff -u -r1.54 request.c
--- server/request.c	19 Jul 2001 00:35:37 -0000	1.54
+++ server/request.c	9 Aug 2001 21:21:58 -0000
@@ -43,6 +43,7 @@
 #define CONFDIR    "/.wine"        /* directory for Wine config relative to $HOME */
 #define SERVERDIR  "/wineserver-"  /* server socket directory (hostname appended) */
 #define SOCKETNAME "socket"        /* name of the socket file */
+#define PIDFILE    "wineserver.pid"
 
 struct master_socket
 {
@@ -420,6 +421,23 @@
     if (!S_ISDIR(st.st_mode)) fatal_error( "%s is not a directory\n", serverdir );
     if (st.st_uid != getuid()) fatal_error( "%s is not owned by you\n", serverdir );
     if (st.st_mode & 077) fatal_error( "%s must not be accessible by other users\n", serverdir );
+}
+
+/* announce our PID in ~/.wine/wineserver-hostname/wineserver.pid */
+void open_pid_file()
+{
+    FILE *pid_file;
+
+    if (!(pid_file = fopen(PIDFILE, "w")))
+	fatal_error("can't write to file %s in ~%s%s.... (%s)\n", PIDFILE, CONFDIR, SERVERDIR, strerror(errno));
+    fprintf(pid_file, "%d\n", getpid());
+    fclose(pid_file);
+}
+
+void close_pid_file()
+{
+    if (unlink(PIDFILE))
+	fprintf( stderr, "wineserver: couldn't remove pid file %s in ~%s%s.... (%s)\n", PIDFILE, CONFDIR, SERVERDIR, strerror(errno));
 }
 
 /* open the master server socket and start waiting for new clients */
Index: server/request.h
===================================================================
RCS file: /home/wine/wine/server/request.h,v
retrieving revision 1.49
diff -u -r1.49 request.h
--- server/request.h	7 Aug 2001 19:19:08 -0000	1.49
+++ server/request.h	9 Aug 2001 21:21:58 -0000
@@ -37,9 +37,11 @@
 extern int send_client_fd( struct process *process, int fd, handle_t handle );
 extern void read_request( struct thread *thread );
 extern void send_reply( struct thread *thread, union generic_request *request );
+extern void open_pid_file(void);
 extern void open_master_socket(void);
 extern void close_master_socket(void);
 extern void lock_master_socket( int locked );
+extern void close_pid_file(void);
 
 extern void trace_request( struct thread *thread, const union generic_request *request );
 extern void trace_reply( struct thread *thread, const union generic_request *request );
Index: documentation/architecture.sgml
===================================================================
RCS file: /home/wine/wine/documentation/architecture.sgml,v
retrieving revision 1.2
diff -u -r1.2 architecture.sgml
--- documentation/architecture.sgml	13 Dec 2000 21:52:37 -0000	1.2
+++ documentation/architecture.sgml	9 Aug 2001 21:21:59 -0000
@@ -76,9 +76,9 @@
       </sect2>
 
       <sect2>
-        <title>The Wineserver</title>
+        <title>The wineserver</title>
         <para>
-          The Wineserver is among the most confusing concepts in Wine.
+          The wineserver is among the most confusing concepts in Wine.
           What is its function in Wine? Well, to be brief, it provides
           Inter-Process Communication (IPC), synchronization, and
           process/thread management. When the wineserver launches, it
@@ -125,13 +125,24 @@
           wineserver duplicates the file descriptor, transmits it to
           the client, and leaves to the client to close the duplicate
           when it's done with it).
-          </para>
+        </para>
+	<para>
+	  To enable people that are running multiple wineservers even
+	  per user (i.e. they run different wine versions to get different
+	  apps to work, e.g. by using wrapper scripts) to kill a specific
+	  wineserver instance, each wineserver writes a process ID file
+	  that can be used to find the pid to kill a wineserver.
+	  This pid file is in the directory that WINEPREFIX is set to
+	  (default is ~/.wine/) in the subdirectory wineserver-<hostname>.
+	  It's simply called wineserver.pid and simply contains one line
+	  consisting of the pid number, just like all *.pid files on Unix do.
+	</para>
       </sect2>
 
       <sect2>
         <title>The Service Thread</title>
         <para>
-          The Wineserver cannot do everything that needs to be done
+          The wineserver cannot do everything that needs to be done
           behind the application's back, considering that it's not
           threaded (so cannot do anything that would block or take any
           significant amount of time), nor does it share the address


More information about the wine-patches mailing list