File: IsUpdateRunning.m

package info (click to toggle)
psychtoolbox-3 3.0.9%2Bsvn2579.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 63,408 kB
  • sloc: ansic: 73,310; cpp: 11,139; objc: 3,129; sh: 1,669; python: 382; php: 272; makefile: 172; java: 113
file content (65 lines) | stat: -rw-r--r-- 2,406 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function isRunning=IsUpdateRunning

% isRunning=IsUpdateRunning
%
% OS X: ___________________________________________________________________
%
% Report the number of processes named "update" which are running.  Only
% one update process at most should run but IsUpdateRunning will report
% higher values if indeed multiple update processes are running.
%
% Priority and Rush shut down the OS X update process when raising priority
% above 0. They use IsUpdateRunning to verify expectations about whether
% update is running prior to taking action.  
%
% OS 9: ___________________________________________________________________
%
% IsUpdateRunning does not exist in OS 9. 
%
% WINDOWS: ________________________________________________________________
% 
% IsUpdateRunning does not exist in Windows.
% 
% _________________________________________________________________________
%
% see also: GetProcessList, GetRawProcesslist, Priority, Rush, finish.

% HISTORY
% 12/06/03  awi     wrote it.
% 7/15/03   awi     wrote it.
% 3/10/09    mk     Prevent check and always return "true" on OS/X >=
%                   10.4.7 to prevent trouble with Matlab R2009a et al.

% Any need for this killupdate schnickschnack at all?
persistent killUpdateNotNeeded;
if isempty(killUpdateNotNeeded)
    % Check if this is MacOS-X 10.4.7 or later. We don't need to kill
    % the update process anymore if that is the case.
    c = Screen('Computer');
    osrelease = sscanf(c.kern.osrelease, '%i.%i.%i');

    if (osrelease(1)==8 & osrelease(2)>=7) | (osrelease(1)>=9) %#ok<OR2,AND2>
        % OS-X 10.4.7 or later -> No need to kill update.
        killUpdateNotNeeded = 1;
    else
        % Pre 10.4.7 system -> Play safe and kill update.
        killUpdateNotNeeded = 0;
    end

    % Override for the scared.
    if exist('AlwaysKillUpdate', 'file')>0
        % Detected a veto file created by the user. We do kill update.
        killUpdateNotNeeded = 0;
    end
end

if killUpdateNotNeeded
    % No. We don't kill update, so we don't care about its state and simply
    % always report it as running:
    isRunning=1;
else
    % Maybe: Need to scan process-list to report run state of update:
    % N.B.: This seems to be broken on Matlab R2009a and later, but as
    % these releases don't run on ancient OS/X versions anymore, who cares?
    isRunning=length(GetProcessDescriptorFromCommandName('update'));
end