"Bad address" error when accessing /dev/clipboard in Cygwin

2

I like to use /dev/clipboard for moving content easily between Windows and Cygwin's command-line tools. It seems like Cygwin has problems with large clipboard contents, though. I get an error like this when I try to access /dev/clipboard after copying a large amount of text on the Windows side:

$ wc -c /dev/clipboard
wc: /dev/clipboard: Bad address
573440 /dev/clipboard

Is there a fixed buffer size for the clipboard that I can somehow increase? Or is this some other issue entirely?

John Sprad

Posted 2013-02-14T21:49:04.330

Reputation: 23

How much is a lot in your case i.e. at what amount of data does it struggle? The example you show above shows ~560kB, but I just tried with 8 megs and it seemed to work just fine. Also, just for curiosity's sake, could you try using getclip and putclip instead of handling the /dev/clipboard device and see if that makes any difference? I doubt it, they probably do the exact same thing, but I'm curious. cat large.txt | putclip ; getclip | wc -c – Costa – 2013-02-15T14:51:43.527

I played around in Notepad for a bit, and found that at 16384 characters, it works fine. At 16385 characters, it breaks with the "Bad address" error. I tried getclip and putclip, though, and those worked fine with even 100 MB of text! Put that in as the answer and I'll accept it. – John Sprad – 2013-02-15T16:57:48.920

Answers

0

I'm not sure why the /dev/clipboard device is problematic for you, but I do know that using the putclip and getclip utilities should be able to handle the job. I regularly use them with multiple megs worth of data and have never run into any trouble.

$ cat large.txt | putclip

$ getclip | wc -c
8665361

They come with the cygutils package... http://cygwin.com/packages/cygutils/

Costa

Posted 2013-02-14T21:49:04.330

Reputation: 491