Subject: Re: bug#63865: 29.0.90; call-process while owning the X selection hangs other processes

From: Spencer Baugh <[email-masked]>
Date: Sat, 03 Jun 2023 09:10:02 -0400

Eli Zaretskii <[email-masked]> writes:
>> If I'm implementing some package and I decide to use call-process for
>> some long operation, then some user uses my package and it runs
>> call-process, and they get bored while waiting and switch away from
>> Emacs, they'll experience a hang in some other application.  That hang
>> seems clearly undesirable!
>
> Then don't design the package such that call-process blocks Emacs for
> prolonged periods of time.  Because this will annoy the users of Emacs
> even before it will be seen by other applications that request X
> selections.

Forget other packages: Emacs itself uses call-process in tons of places
where it will run for prolonged periods of time!

In fact, I just ran "C-x p g call-process" to search for instances, only
to find that that command itself uses call-process and hung my other
applications!

Should we port all these instances away from using call-process to avoid
this behavior?  I certainly would like to, because I don't like that
when I do a particularly long process-find-regexp or shell-command or
any other operation which uses call-process, it doesn't just hang Emacs,
it hangs basically my whole OS.

>> I'm personally working around this by replacing call-process with
>> start-process and accept-process-output.  Because otherwise my packages
>> (and any other package using call-process ever) will cause random hangs
>> in other applications, which is obviously bad and not something anyone
>> would want.
>> 
>> So perhaps call-process on Unix should be reimplemented in terms of
>> those functions?  Or if that would change behavior too much, perhaps
>> call-process should be deprecated in favor of some new helper built on
>> those?
>
> call-process has its use cases, which are important, and we will not
> deprecate it.
>
> You can easily emulate call-process with start-process if you need to
> do so, so Emacs gives you both possibilities (and expects you to use
> whatever is right in each case).

What use case does call-process have on Unix, which an emulation in
terms of start-process would not also satisfy?