How to lock screen of host machine with TDM on Sierra I regularly use my iMac as an external display for my macbook using target display mode (TDM).  Since upgrading my iMac to Sierra, the screen locking behavior has changed in a disturbing way.  I'm hoping there's a configuration flag I can set to revert to the old behavior.  Here's the situation:


I unlock the iMac.  (log in to my account)
Connect the two macs with thunderbolt.
Hit command-f2 to enable TDM.  iMac is now an external monitor for macbook.
Use the macbook for a while.  Lock the screen, walk away.  Wait a long time.
Unplug the thunderbolt cable.
The iMac is logged in and unlocked. (!!)


Previously (before Sierra) on step 6, the iMac would have its account locked, which is of course what I want my mac to do if I haven't been using it in a long time.  

How can I get my iMac to lock its account when it's being used as an external monitor in TDM mode?  Right now, it seems using TDM is a major security hole for the iMac.
This should not happen at all if your iMac locks itself after a period of time without TDM.
To lock your iMac's account after a period of time, follow these steps:

Choose Apple menu &gt; System Preferences, click Security &amp; Privacy, then click General.

Click the lock icon  to unlock it, then enter an administrator name and password.

Click Advanced.

Select “Log out after... minutes of inactivity.”

Set the amount of time before the user is automatically logged out.


(quoted from https://support.apple.com/kb/PH18670?locale=en_US)
.
It definitively is supported to log out a user while using Target Display Mode (TDM):

Any apps that are open on your iMac remain open and active while your iMac is in Target Display Mode. (...)
If you've set your iMac to automatically log out, apps are paused or closed when this happens but your iMac remains in Target Display Mode.

From: https://support.apple.com/en-us/HT204592#options
.
Also check these options in System Preferences:

Energy Saver &gt; Wake for network access (uncheck)
Security &amp; Privacy &gt; General &gt; Require password immediately after sleep or screen saver begins (check)
Desktop &amp; Screen Saver &gt; Screen Saver &gt; Start after: 1 Minute

Please let me know if this solves the issue.