tfabris / CrowCam

A set of Bash scripts to control and maintain a YouTube live cam from a Synology NAS.
GNU General Public License v3.0
4 stars 3 forks source link

Kill statement does not work correctly on MacOS X #6

Closed tfabris closed 5 years ago

tfabris commented 5 years ago

When deliberately inducing a failure in a subroutine which is intended to invoke the kill/trap method of exiting from a subroutine, I'm now getting a message saying that my syntax for Kill is wrong. Likely due to a difference between Mac OSX and Linux implementations of the Kill statement.

Repro Steps:

Output:

CrowCam Controller - Checking status of YouTube Live Broadcast feature.
CrowCam Controller - Cookie file not present - authenticating.
CrowCam Controller - Response: .
CrowCam Controller - The call to authenticate with the Synology Web API failed. Exiting program. Response: .
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
CrowCam Controller - We are after our sunset/stop time. YouTube Live Broadcast is down. It should be down at this time. Nothing to do.
CrowCam Controller - Checking status of YouTube Live Broadcast feature.
CrowCam Controller - Calling: wget -qO- --load-cookies wgetcookies.txt --timeout=10 "http://192.168.0.88:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.YoutubeLive&version=1&method=Load".
tfabris commented 5 years ago

Found the issue. My syntax for the Kill statement was correct, but the problem is that the scheme depended upon $BASHPID, and that variable was only introduced in Bash version 4.0, and Mac only has bash version 3.

To do: Figure out how to work around this.

tfabris commented 5 years ago

Possible work-around here: https://stackoverflow.com/questions/9119885/how-to-get-the-process-id-of-a-bash-subprocess-on-command-line

tfabris commented 5 years ago

The possible listed work-around didn't work for me. Closing issue as "cannot fix".