On Mon, 05 Sep 2016, Richard Owlett wrote: > I realized I had miss-specified options. As data was multiple GB and target > was a USB connected flash drive I wished an immediate termination.
Usually there is no clean way to do this, and you have to wait for the process to notice the signal, and abort. > It seems there should be a better option? There is none, at least for "cp" and just about everything else that does normal writes (i.e. not direct I/O bypassing the kernel page cache). Maybe doing direct I/O using "dd o=direct" with a suitable (not too big) buffer size would work differently, but I am not sure about that at all. Anyway, from what you described, a lot of data to write was already submitted by "cp" to the kernel, and the "cp" process would be in "D" (uninterruptible sleep) state because it accumulated too many dirty pages (pending writes) already and was still trying to queue up more writes. Eventually, the kernel would have flushed enough data to the device and would decide to waken "cp" up to get more data to write, at which point "cp" would notice the SIGINT from ^C, and abort. The kernel would continue to flush the remaining data that had already been submitted for writing, though, so device writes would not immediately stop. -- Henrique Holschuh