gpgme 0.2.3 usage issues (?) resulting in gpgme pending after wait

Charles Duffy cduffy at
Fri Nov 30 04:42:02 CET 2001

As per the subject. Hopefully I'm making some incorrect usage
assumptions, and this whole thing can be ironed out quickly.

I'm working on Java bindings to gpgme using CNI. It's almost finished
enough for my application (which needs only signatures); I may or may
not continue development after the app works, depending on interest and
my time constraints. 

Anyhow, my test code first writes to indata and then calls
gpgme_wait(context, false) just prior to gpgme_op_sign(context, indata,
outdata, GPGME_SIG_MODE_NORMAL). I *presume* that this would cause
anything pending (reading the input data?) to be finished. However, even
at the end of the wait call, context->pending is 1 and so the
gpgme_op_sign fails with GPGME_Busy. Checking the process table, I also
notice that the gpg instance gpgme refers to has zombied as of the wait

The (really rough) test which is failing is included below; the API
pretty much is what it looks like. I'd be much obliged to anyone who'd
be so kind as to point out any glaring error, or point me in the
directions of any docs which might clarify what I'm doing wrong.


import java.util.Vector;
import java.util.Iterator;

class MyCallback extends gnu.gpgme.PassphraseCallback {
    String retval;
    public MyCallback(String retval) {
	this.retval = retval;
    public String getPassphrase(String desc) {
	return retval;

class test {
    public static void main(String[] args) {
	try {

	    MyCallback mc = new MyCallback("Alas, I am but a test!");

	    gnu.gpgme.Gpgme foo = new gnu.gpgme.Gpgme();
	    gnu.gpgme.GpgmeData testInput  = new gnu.gpgme.GpgmeData();
	    gnu.gpgme.GpgmeData testOutput = new gnu.gpgme.GpgmeData();


	    int keyCount = 0;
	    Vector keys = foo.getKeys("test", true);
	    for(Iterator it = keys.iterator(); it.hasNext();) {
		gnu.gpgme.GpgmeKey key = (gnu.gpgme.GpgmeKey);
		if(key != null) {
		    if(keyCount == 0) foo.addSigner(key); // add the first matching privkey; only list the others

	    System.out.println(keyCount + " keys printed.");

	    System.out.println("Setting passphrase callback");

	    System.out.println("Reading string into buffer");
	    testInput.write((new String("Foo bar baz")).getBytes());

	    System.out.println("Signing data");
	    foo.signData(testInput, testOutput, gnu.gpgme.GpgmeSigMode.GPGME_SIG_MODE_NORMAL);

	    System.out.println("Reading results");
	    byte bar[] =;
	} catch(gnu.gpgme.GpgmeError e) {
	    System.out.println("GPGME Error: " + e.getErrorStr());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : /pipermail/attachments/20011130/5c95a386/attachment.bin

More information about the Gnupg-devel mailing list