/dev/clipboard sometimes fails to set CF_UNICODETEXT data.

Takashi Yano takashi.yano@nifty.ne.jp
Sat Jul 2 03:20:56 GMT 2022


Hello,

In one of my PCs,
dd if=/dev/urandom count=10 | xxd > /dev/clipboard
sometimes fails to set CF_UNICODETEXT data.
As a result, pasting clipboard to notepad does not work.

Even in the case, cygnativeformat data is set correctly.
So, "cat /dev/clipboard" works.

This problem depends on machine very much.

My one PC with Xeon E3-1281 v3 CPU has a high probability of failure,
however, another machine with Core i7-6700K CPU does not.

I looked into this problem, and found OpenClipboard() for
CF_UNICODETEXT fails. It seems that OpenClipboard() just
after CloseClipboard() has high probability of failure.

You can see the following test case immediately stops with error.
Even with Core i7-6700K CPU machine above, the test case fails.

#include <windows.h>
#include <stdio.h>

int main()
{
	for (;;) {
		if (!OpenClipboard(0)) {
			printf("Open error.\n");
			break;
		}
		if (!EmptyClipboard()) {
			printf("Empty error.\n");
			break;
		}
		if (!CloseClipboard()) {
			printf("Cloes error.\n");
			break;
		}
	}
	return 0;
}

I also found the patch attached solves the issue.

I would appreciate any suggestion.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Cygwin-clipboard-Add-workaround-for-setting-clipboar.patch
Type: application/octet-stream
Size: 2564 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20220702/3e0425a6/attachment.obj>


More information about the Cygwin mailing list