(defun run-latexmk ()
"Asynchronously run `latexmk' and attach a sentinel to it"
(let ((process (start-process "latexmk" "*output*"
"/bin/sh" "-c" "echo KO; false")))
(set-process-sentinel process 'latexmk-sentinel)))
(defun latexmk-sentinel (p e)
"Display the pdf if `latexmk' was successful"
(when (= 0 (process-exit-status p))
(start-process "displaypdf" "*output*"
"/bin/echo" "DISPLAY PDF")))
;; Example use
(with-current-buffer (get-buffer-create "*output*") (erase-buffer))
(run-latexmk)