If you have two services that shouldn't run at the same time, consider adding a
Conflicts= entry in the
[Unit] section of your test service:
A space-separated list of unit names. Configures negative requirement
dependencies. If a unit has a
Conflicts= setting on another unit,
starting the former will stop the latter and vice versa. Note that
this setting is independent of and orthogonal to the
Before= ordering dependencies.
If a unit A that conflicts with a unit B is scheduled to be started at
the same time as B, the transaction will either fail (in case both are
required part of the transaction) or be modified to be fixed (in case
one or both jobs are not a required part of the transaction). In the
latter case, the job that is not the required will be removed, or in
case both are not required, the unit that conflicts will be started
and the unit that is conflicted is stopped.
So this may work (not tested):
Description=Pin debugging of sshd (copied from sshd.service)
After=syslog.target network.target auditd.service
ExecStart=/path/to/pin -t somepintool.so -- /usr/sbin/sshd -D -e
systemd can do the work of making sure you don't have both services running and show do the stopping and starting correctly. Most of the services I see that use this have
Conflicts=shutdown.target, so it appears it's usually used for making sure services finish before shutdown occurs, but there's nothing preventing you from using this for other purposes!