44

Since I upgraded my Mac OS, some programs get this error when running:

Killed: 9

I even execute them via sudo but they won't work.

Any idea?

0

7 Answers 7

44

Open a new terminal window/tab

0
18

If you replace a signed macOS binary by using cp instead of mv then macOS caches the signature, doesn't like the look of it because the file changed and kills your process when you try and start the new binary. Clearly, this is a bug in macOS. We had to update our install scripts to copy the file a different way.

3
  • I find the terminal CLI enormously useful for debugging network rout problems and service analysis. Unfortunately Apple does not understand that SSH cannot replace this in their responses of "just use SSH, it's more secure" Unfortunately with the update to macOS 12, I'm now getting a Killed: 9. I remember when Mac == Easy back in the 90's
    – Cerniuk
    Oct 27, 2021 at 21:07
  • 4
    Thank you for your answer. I solved the Killed: 9 error, by running rm then cp instead of just cp. Do you have a reference on this problem ? Oct 31, 2021 at 18:29
  • I had the same when I upgraded a binary azcopy by copying the newer version over the top of it. I had used xattr to remove com.apple.quarantine and com.apple.macl attributes so this may have had some bearing on it as well. A reboot actually reverted the azcopy binary back to the previous version.
    – Ed Randall
    May 5, 2022 at 10:20
4
  1. Download UPX. For example, using Homebrew, run brew install upx.

  2. Decompress the binary:

    upx -d /path/to/App.app/MacOS/App
    

Also see “This UPX compressed binary contains an invalid Mach-O header and cannot be loaded.”

2
  • Dang! My compressed binaries used to work fine on the M1, but something changed over the last couple of months and they no long work when run through upx =(
    – Justin
    May 4, 2022 at 17:31
  • 1
    The executable being killed isn't compressed with upx, how does this have any effect?
    – Ed Randall
    May 5, 2022 at 10:11
0

in my case there was some process called syspolicy or something like that, once i killed that process, running my command python3 no longer returned killed 9.

0

I was able to fix it after running this command found in this homebrew github discussion:

brew reinstall pcre2 gettext

Hope this helps

0

This fixed it for me:

codesign --sign - --force --preserve-metadata=entitlements,requirements,flags,runtime <path-to-binary>

this command replaces the current signature in the binary file with a new one preserving the old information, in this way you reset the previous one that "alarms" the OS. more info here

original answer

0
-1

I tried resetting the binaries and it did fix the issue for me. To reset the binaries for the macOS M1 terminal, you can follow these steps:

  1. Open the Terminal application on your Mac.
  2. Type the following command and press Enter: echo $PATH. This will display the current path for the terminal.
  3. Copy the output of the command and save it in a text editor for reference.
  4. Type the following command and press Enter: echo $SHELL. This will display the current shell being used by the terminal.
  5. If the output of the command is /bin/bash, type the following command and press Enter: nano ~/.bash_profile. If the output is /bin/zsh, type the following command and press Enter: nano ~/.zshrc. This will open the shell configuration file in the nano text editor.
  6. Scroll down to the bottom of the file and add the following line: export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin. This will reset the path to the default macOS path.
  7. Save the file by pressing Control+O, then press Enter to confirm, and then exit the editor by pressing Control+X.
  8. Type the following command and press Enter: source ~/.bash_profile or source ~/.zshrc, depending on which shell you are using.
  9. Type the following command and press Enter: echo $PATH. This will display the new path for the terminal.
  10. Verify that the path is correct by running a command that is installed by default on macOS, such as ls or pwd.

These steps should reset the binaries for the terminal and restore the default macOS path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .