Index: /psi/trunk/src/tools/openpgp/gnupg.cpp
===================================================================
--- /psi/trunk/src/tools/openpgp/gnupg.cpp	(revision 85)
+++ /psi/trunk/src/tools/openpgp/gnupg.cpp	(revision 86)
@@ -113,5 +113,5 @@
 
 #ifdef GPG_DEBUG
-	printf("gpg bin=[%s]\n", bin.latin1());
+	qDebug("### gpg bin=[%s]", bin.latin1());
 #endif
 	d = new Private(bin);
@@ -296,7 +296,7 @@
 {
 #ifdef GPG_DEBUG
-	printf("GnuPG initialization complete\n");
-	printf(" Secret Keyring: [%s]\n", d->secretWatch.fileName().latin1());
-	printf(" Public Keyring: [%s]\n", d->publicWatch.fileName().latin1());
+	qDebug("### GnuPG initialization complete");
+	qDebug("### Secret Keyring: [%s]", d->secretWatch.fileName().latin1());
+	qDebug("### Public Keyring: [%s]", d->publicWatch.fileName().latin1());
 #endif
 	initFinished(b, err);
@@ -461,5 +461,5 @@
 		d->secretDirty = true;
 #ifdef GPG_DEBUG
-		printf("Secret keys updated!\n");
+		qDebug("### Secret keys updated!");
 #endif
 	}
@@ -467,5 +467,5 @@
 		d->publicDirty = true;
 #ifdef GPG_DEBUG
-		printf("Public keys updated!\n");
+		qDebug("### Public keys updated!");
 #endif
 	}
Index: /psi/trunk/src/tools/openpgp/gpgop.cpp
===================================================================
--- /psi/trunk/src/tools/openpgp/gpgop.cpp	(revision 85)
+++ /psi/trunk/src/tools/openpgp/gpgop.cpp	(revision 86)
@@ -365,5 +365,5 @@
 {
 #ifdef GPG_DEBUG
-	printf("{%s}\n", str.latin1());
+	qDebug("### {%s}", str.latin1());
 #endif
 	QString s, rest;
@@ -435,5 +435,5 @@
 
 #ifdef GPG_DEBUG
-	printf("GPG Finished: ");
+	qDebug("### GPG Finished: ");
 #endif
 
@@ -443,5 +443,5 @@
 		clean = false;
 #ifdef GPG_DEBUG
-		printf("bad exit.. crash?\n");
+		qDebug("### bad exit.. crash?");
 #endif
 	}
@@ -449,5 +449,5 @@
 		exitStatus = d->proc->exitStatus();
 #ifdef GPG_DEBUG
-		printf("exitStatus=%d\n", exitStatus);
+		qDebug("### exitStatus=%d", exitStatus);
 #endif
 	}
@@ -472,6 +472,6 @@
 
 #ifdef GPG_DEBUG
-	printf("stdout: [%s]\n", outstr.latin1());
-	printf("stderr: [%s]\n", errstr.latin1());
+	qDebug("### stdout: [%s]", outstr.latin1());
+	qDebug("### stderr: [%s]", errstr.latin1());
 #endif
 
Index: /psi/trunk/src/tools/openpgp/gpgproc/gpgproc.cpp
===================================================================
--- /psi/trunk/src/tools/openpgp/gpgproc/gpgproc.cpp	(revision 85)
+++ /psi/trunk/src/tools/openpgp/gpgproc/gpgproc.cpp	(revision 86)
@@ -106,5 +106,5 @@
 	if(!d->pipeAux.open()) {
 #ifdef GPG_DEBUG
-		printf("Error creating pipeAux\n");
+		qDebug("### Error creating pipeAux");
 #endif
 		closePipes();
@@ -113,5 +113,5 @@
 	if(!d->pipeCommand.open()) {
 #ifdef GPG_DEBUG
-		printf("Error creating pipeCommand\n");
+		qDebug("### Error creating pipeCommand");
 #endif
 		closePipes();
@@ -120,5 +120,5 @@
 	if(!d->pipeStatus.open()) {
 #ifdef GPG_DEBUG
-		printf("Error creating pipeStatus\n");
+		qDebug("### Error creating pipeStatus");
 #endif
 		closePipes();
@@ -130,5 +130,5 @@
 	if(!d->pipeAux.writeEnd().winDupHandle()) {
 #ifdef GPG_DEBUG
-		printf("Error dup'ing pipeAux\n");
+		qDebug("### Error dup'ing pipeAux");
 #endif
 		closePipes();
@@ -137,5 +137,5 @@
 	if(!d->pipeCommand.writeEnd().winDupHandle()) {
 #ifdef GPG_DEBUG
-		printf("Error dup'ing pipeCommand\n");
+		qDebug("### Error dup'ing pipeCommand");
 #endif
 		closePipes();
@@ -144,5 +144,5 @@
 	if(!d->pipeStatus.readEnd().winDupHandle()) {
 #ifdef GPG_DEBUG
-		printf("Error dup'ing pipeStatus\n");
+		qDebug("### Error dup'ing pipeStatus");
 #endif
 		closePipes();
@@ -168,7 +168,7 @@
 		QCString cs2 = buf.data();
 		if(cs != cs2)
-			printf("Pipe test failed.\n");
+			qDebug("### Pipe test failed.");
 		else
-			printf("Pipe test succeeded.\n");
+			qDebug("### Pipe test succeeded.");
 	}*/
 
@@ -180,5 +180,5 @@
 
 #ifdef GPG_DEBUG
-	printf("Pipe setup complete.\n");
+	qDebug("### Pipe setup complete.");
 #endif
 
@@ -188,6 +188,4 @@
 
 	if(useExtra) {
-		fullargs += "--enable-special-filenames";
-
 		fullargs += "--status-fd";
 		fullargs += d->pipeStatus.writeEnd().toString();
@@ -197,19 +195,21 @@
 	}
 
+	bool seen_special_filenames = false;        
 	for(QStringList::ConstIterator it = args.begin(); it != args.end(); ++it) {
 		const QString &a = (*it);
-		if(a == "-&?")
-			fullargs += (QString("-&") + d->pipeAux.readEnd().toString());
-		else
+		if(a == "-&?") {
+			seen_special_filenames = true;
+			fullargs += (QString("\"-&") + d->pipeAux.readEnd().toString() + "\"");
+		} else {
 			fullargs += a;
-	}
+		}
+	}
+	// insert --enable-special-filenames after --no-tty
+	if(seen_special_filenames)
+		fullargs.insert(fullargs.at(2), "--enable-special-filenames");
 
 	// show full command
 #ifdef GPG_DEBUG
-	printf("GPGProc: ");
-	for(QStringList::ConstIterator it2 = fullargs.begin(); it2 != fullargs.end(); ++it2) {
-		printf("%s ", (*it2).latin1());
-	}
-	printf("\n");
+	qDebug("### GPGProc: %s", fullargs.join(" ").latin1());
 #endif
 
@@ -223,9 +223,4 @@
 	d->proc->setClosePipeList(plist);
 #endif
-	/// @todo (dmik)
-	//  On Unix, it is done when SProcess is destructed. On OS/2 as well as on
-	//  Win32, SProcess is not used, but we use the same QPipe implelentation
-	//  on OS/2 as Unix does, so we need to use the similar technuque to close
-	//  them... Need to investigate this file (i.e. usage) in detail.
 
 	connect(d->proc, SIGNAL(readyReadStdout()), SLOT(proc_readyReadStdout()));
@@ -327,4 +322,8 @@
 #endif
 	processExited();
+
+#if defined(Q_OS_OS2)
+	closePipes();
+#endif
 }
 
