Crash when using writeStdin()

Kevin Krammer kevin.krammer at gmx.at
Tue Apr 23 11:56:01 BST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday, 23. April 2002 17:05, Zenith Lau wrote:
> I want to write a kde program to communicate with a shellscript, and I use
> KProcess to run the shellscript. However, the program always crashes when
> it try to write to stdout. How can I solve this problem?

This is a user list, subscribe to kde-devel for development questions.

>
>
> ********************************************************
> writer.cpp
> ********************************************************
> Writer::Writer(){
> 	proc = new KProcess();
> 	*proc<<"/root/test";
> 	connect(proc, SIGNAL(receivedStdout(KProcess*, char*, int)),
>   	 	 this, SLOT(recv(KProcess*, char*, int)));
> 	connect(proc, SIGNAL(wroteStdin(KProcess*)), this,
> 		 SLOT(closeSlot(KProcess*)));
> 	proc->start(KProcess::Block, (KProcess::Communication)(KProcess::Stdin |
>             KProcess::Stdout));

KProcess::Block blocks your program until the child has finished.
Thus, whenever you get to the sending method, the shellscript has already 
exited (see KProcess signal processExited)

Cheers,
Kevin

- -- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Krammer <kevin.krammer at gmx.at>
Developer at the Kmud Project http://www.kmud.de/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8xT3GnKMhG6pzZJIRAt3MAJ9Ws4NGJ8reoJxjvGYYV0briqzHZwCfUlV4
QyKrGJhxI1WrVmLJy8ScQjY=
=WV2J
-----END PGP SIGNATURE-----
___________________________________________________
This message is from the kde mailing list.
Account management:  http://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.




More information about the kde mailing list