call-process is running, emacs will processing events,
with-timeout will not work without this:
The timeout is checked whenever Emacs waits for some kind of external
event (such as keyboard input, input from subprocesses, or a certain
time); if the program loops without waiting in any way, the timeout
will not be detected.
You can still use
with-timeout with (semi) synchronous processes.
You will actually use a asynchronous process but will synchrously wait while it is running, Emacs will process events when you run
sit-for, which you can run for 0 seconds. You can then use the timeout-forms argument of
with-timeout to kill the process if it is still running when the timeout fires.
(with-current-buffer (get-buffer-create "*my-proc-buffer*")
(let ((proc (start-process "myproc" (current-buffer) "bash" "-c" "sleep 4"))) ;; start an async process
(with-timeout (2 (kill-process proc)) ;; on timeout, kill the process
(while (process-live-p proc) ;; while process is running
(sit-for .05)) ;; let emacs read events and run timmers (and check for timeout)
(message "finished on time!!")))) ;; this will run only if there is no timeout