Fossil SCM

More Win32 support for the backoffice processing.

mistachkin 2018-08-02 01:53 UTC win32Proc
Commit f13ae35f5e2cfd1c293c78d43e2590fd88689ce44ee402401fb74766487b9553
1 file changed +20 -2
+20 -2
--- src/backoffice.c
+++ src/backoffice.c
@@ -132,17 +132,35 @@
132132
" VALUES('backoffice','%lld %lld %lld %lld',now())",
133133
pLease->idCurrent, pLease->tmCurrent,
134134
pLease->idNext, pLease->tmNext);
135135
}
136136
137
+/*
138
+** Check to see if the specified Win32 process is still alive. It
139
+** should be noted that even if this function returns non-zero, the
140
+** process may die before another operation on it can be completed.
141
+*/
142
+#if defined(_WIN32)
143
+#ifndef PROCESS_QUERY_LIMITED_INFORMATION
144
+# define PROCESS_QUERY_LIMITED_INFORMATION (0x1000)
145
+#endif
146
+static int backofficeWin32ProcessExists(DWORD dwProcessId){
147
+ HANDLE hProcess;
148
+ hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,FALSE,dwProcessId);
149
+ if( hProcess==NULL ) return 0;
150
+ CloseHandle(hProcess);
151
+ return 1;
152
+}
153
+#endif
154
+
137155
/*
138156
** Check to see if the process identified by selfId is alive. If
139157
** we cannot prove the the process is dead, return true.
140158
*/
141159
static int backofficeProcessExists(sqlite3_uint64 pid){
142160
#if defined(_WIN32)
143
- return 1;
161
+ return pid>0 && backofficeWin32ProcessExists((DWORD)pid)!=0;
144162
#else
145163
return pid>0 && kill((pid_t)pid, 0)==0;
146164
#endif
147165
}
148166
@@ -150,11 +168,11 @@
150168
** Check to see if the process identified by selfId has finished. If
151169
** we cannot prove the the process is still running, return true.
152170
*/
153171
static int backofficeProcessDone(sqlite3_uint64 pid){
154172
#if defined(_WIN32)
155
- return 1;
173
+ return pid<=0 || backofficeWin32ProcessExists((DWORD)pid)==0;
156174
#else
157175
return pid<=0 || kill((pid_t)pid, 0)!=0;
158176
#endif
159177
}
160178
161179
--- src/backoffice.c
+++ src/backoffice.c
@@ -132,17 +132,35 @@
132 " VALUES('backoffice','%lld %lld %lld %lld',now())",
133 pLease->idCurrent, pLease->tmCurrent,
134 pLease->idNext, pLease->tmNext);
135 }
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137 /*
138 ** Check to see if the process identified by selfId is alive. If
139 ** we cannot prove the the process is dead, return true.
140 */
141 static int backofficeProcessExists(sqlite3_uint64 pid){
142 #if defined(_WIN32)
143 return 1;
144 #else
145 return pid>0 && kill((pid_t)pid, 0)==0;
146 #endif
147 }
148
@@ -150,11 +168,11 @@
150 ** Check to see if the process identified by selfId has finished. If
151 ** we cannot prove the the process is still running, return true.
152 */
153 static int backofficeProcessDone(sqlite3_uint64 pid){
154 #if defined(_WIN32)
155 return 1;
156 #else
157 return pid<=0 || kill((pid_t)pid, 0)!=0;
158 #endif
159 }
160
161
--- src/backoffice.c
+++ src/backoffice.c
@@ -132,17 +132,35 @@
132 " VALUES('backoffice','%lld %lld %lld %lld',now())",
133 pLease->idCurrent, pLease->tmCurrent,
134 pLease->idNext, pLease->tmNext);
135 }
136
137 /*
138 ** Check to see if the specified Win32 process is still alive. It
139 ** should be noted that even if this function returns non-zero, the
140 ** process may die before another operation on it can be completed.
141 */
142 #if defined(_WIN32)
143 #ifndef PROCESS_QUERY_LIMITED_INFORMATION
144 # define PROCESS_QUERY_LIMITED_INFORMATION (0x1000)
145 #endif
146 static int backofficeWin32ProcessExists(DWORD dwProcessId){
147 HANDLE hProcess;
148 hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,FALSE,dwProcessId);
149 if( hProcess==NULL ) return 0;
150 CloseHandle(hProcess);
151 return 1;
152 }
153 #endif
154
155 /*
156 ** Check to see if the process identified by selfId is alive. If
157 ** we cannot prove the the process is dead, return true.
158 */
159 static int backofficeProcessExists(sqlite3_uint64 pid){
160 #if defined(_WIN32)
161 return pid>0 && backofficeWin32ProcessExists((DWORD)pid)!=0;
162 #else
163 return pid>0 && kill((pid_t)pid, 0)==0;
164 #endif
165 }
166
@@ -150,11 +168,11 @@
168 ** Check to see if the process identified by selfId has finished. If
169 ** we cannot prove the the process is still running, return true.
170 */
171 static int backofficeProcessDone(sqlite3_uint64 pid){
172 #if defined(_WIN32)
173 return pid<=0 || backofficeWin32ProcessExists((DWORD)pid)==0;
174 #else
175 return pid<=0 || kill((pid_t)pid, 0)!=0;
176 #endif
177 }
178
179

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button