Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.mac.system > #125888

Re: photolibraryd

From Jolly Roger <jollyroger@pobox.com>
Newsgroups comp.sys.mac.system
Subject Re: photolibraryd
Date 2019-08-22 15:52 +0000
Organization People for the Ethical Treatment of Pirates
Message-ID <gs7s1mFio16U1@mid.individual.net> (permalink)
References (2 earlier) <qj80nf$klh$1@dont-email.me> <grqq5eFoonbU1@mid.individual.net> <qj9v3h$s56$1@dont-email.me> <gru2euFfn7fU1@mid.individual.net> <qjmclf$me6$1@dont-email.me>

Show all headers | View raw


On 2019-08-22, Király <me@home.spamsucks.ca> wrote:
> Jolly Roger <jollyroger@pobox.com> wrote:
>> Welcome. : )
>
> Hi JR,
>
> The script sort of works intermittently. If often fails with this error: 
> sh: line 0: kill: 49979
> 49986: arguments must be process or job IDs
>
> Do you know what's wrong?
> Thank you.

It looks like pgrep returned two PIDs, which must mean there are two
photolibraryd processes running at the time. Could it be that Photos was
open in two macOS user accounts at the time?

At any rate, I've modified the script to handle that case by killing
each process in the list:

-- begin script
property waiting : false

on run
	set waiting to false
end run

on idle
	if waiting then
		if not AppIsRunning("Photos") then
			set processIDs to ProcessIsRunning("photolibraryd")
			repeat with nextPID in the paragraphs of processIDs
				if nextPID is not "" then
					set killResults to do shell script ("kill -9 " & nextPID as text)
					if killResults is not "" then
						tell application "System Events" to display alert "Potential Error" message ("Kill command returned unexpected results: " & return & return & killResults as text) buttons {"Thanks"} default button 1
					end if
				end if
			end repeat
		end if
	else
		if AppIsRunning("Photos") then
			set waiting to true
		end if
	end if
	
	return 1
end idle

on AppIsRunning(appName)
	tell application "System Events"
		set isRunning to (appName is in (name of every process))
	end tell
	return isRunning
end AppIsRunning

on ProcessIsRunning(processName)
	set processIDs to ""
	try
		set processIDs to do shell script ("pgrep " & processName as text)
	end try
	return processIDs
end ProcessIsRunning
-- end script

-- 
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR

Back to comp.sys.mac.system | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

photolibraryd me@home.spamsucks.ca (Király) - 2019-08-16 16:15 +0000
  Re: photolibraryd ~BD~ <dgb@nomail.invalid> - 2019-08-16 17:25 +0100
  Re: photolibraryd Jolly Roger <jollyroger@pobox.com> - 2019-08-16 16:41 +0000
    Re: photolibraryd me@home.spamsucks.ca (Király) - 2019-08-17 04:44 +0000
      Re: photolibraryd gtr <xxx@yyy.zzz> - 2019-08-16 22:49 -0700
      Re: photolibraryd Jolly Roger <jollyroger@pobox.com> - 2019-08-17 17:00 +0000
        Re: photolibraryd me@home.spamsucks.ca (Király) - 2019-08-17 22:29 +0000
          Re: photolibraryd Jolly Roger <jollyroger@pobox.com> - 2019-08-18 22:40 +0000
            Re: photolibraryd me@home.spamsucks.ca (Király) - 2019-08-22 15:34 +0000
              Re: photolibraryd Jolly Roger <jollyroger@pobox.com> - 2019-08-22 15:52 +0000
                Re: photolibraryd gtr <xxx@yyy.zzz> - 2019-08-22 21:49 -0700
                Re: photolibraryd Jolly Roger <jollyroger@pobox.com> - 2019-08-23 18:31 +0000
                Re: photolibraryd gtr <xxx@yyy.zzz> - 2019-08-23 17:39 -0700
                Re: photolibraryd Jolly Roger <jollyroger@pobox.com> - 2019-08-24 19:27 +0000
                Re: photolibraryd me@home.spamsucks.ca (Király) - 2019-08-26 15:41 +0000
                Re: photolibraryd Jolly Roger <jollyroger@pobox.com> - 2019-08-27 23:09 +0000

csiph-web