bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63865: 29.0.90; call-process while owning the X selection hangs othe


From: Spencer Baugh
Subject: bug#63865: 29.0.90; call-process while owning the X selection hangs other processes
Date: Sat, 03 Jun 2023 10:12:41 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Spencer Baugh <sbaugh@janestreet.com>
>> Cc: luangruo@yahoo.com,  63865@debbugs.gnu.org
>> Date: Sat, 03 Jun 2023 09:10:02 -0400
>> 
>> Eli Zaretskii <eliz@gnu.org> 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!
>
> Really?  "tons of places where it will run for prolonged periods of
> time"? what is "prolonged period of time" for this purpose?  Aren't
> you a tad exaggerating?

"prolonged period of time" is anything over a second.

I see tons of calls to call-process with potentially long-running
programs.  "find", "gcc", "grep", "awk"... and depending on the user's
system, *any* subprocess call can potentially run for a long time.

But again, the point isn't just that they can potentially run for a long
time.  It's that *the user's whole system can be unusable* while they
run.  We are not just blocking Emacs, we are (sometimes) blocking
*everything*.

>> Should we port all these instances away from using call-process to avoid
>> this behavior?
>
> There's no general answer to that, we should examine each case
> separately.

A general answer could be fixing call-process to not hang other
processes.

>> > 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?
>
> When the process returns quickly.  call-process is significantly
> simpler to use than start-process+wait, so doing that when unnecessary
> is a complication we shouldn't take.

What I mean was an emulation like this:

(defun my-call-process (program &optional destination &rest args)
  (let ((process (make-process :name "call-process"
                               :buffer destination
                               :command (cons program args))))
    (while (accept-process-output process))))

my-call-process is missing a few arguments that the real call-process
has.  But if this is all I use, is there *any* reason to *not* use
my-call-process on Linux?

There is at least one strong reason to use it: It won't hang other
processes.

> Anyway, this kind of discussion doesn't belong in a bug report about X
> selections.

But the entire point of this discussion, for me, is to fix the
X-selection-related hangs which Emacs currently causes when in
call-process.  i.e., this bug report.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]