Это не решение imagemagic, но
sips -r 90 *.JPG
поворачивает все изображения, оканчивающиеся на .JPG, на 90 градусов. Это хороший лайнер.
Zócalo unix abstracto(man 7 unix
):
- abstract: an abstract socket address is distinguished (from a pathname socket) by the fact that sun_path[0] is a null byte ('\0'). The socket's address in this namespace is given by the additional bytes in sun_path that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) The name has no connection with filesystem pathnames. [...]
Su principal interés aquí es que este socket no permanece cuando el proceso que lo creó muere. Afortunadamente socat
proporciona un método ABSTRACT-LISTEN
específicamente para sockets abstractos (que evita tener que manejar '\0'
en parámetros y shell ). Permitiendo así implementar este método python en shell:
#!/bin/sh
socat ABSTRACT-LISTEN:/myownapplock - >/dev/null &
socatpid=$!
sleep 2 # wait for socat to have executed and be listening or have failed
if pgrep -P $$ '^socat$'; then
locked=yes
else
locked=no
echo >&2 'Lock failed.'
exit 1
fi
my-proc
kill $socatpid # cleanup once my-proc is done
La ejecución del mismo código por segunda vez fallará. Estoy seguro de que el sleep 2
se puede mejorar, pero este código sigue siendo carrera -libre (siempre que socat tarde menos de 2 segundos en comenzar ). El socket abstracto se puede ver, por ejemplo, con netstat -xlp|fgrep @/myownapplock
.