--Boundary-03=_bUGJ/+YWKvxBAjx Content-Type: multipart/mixed; boundary="Boundary-01=_XUGJ/PwOi4XVE4L" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_XUGJ/PwOi4XVE4L Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, the attached KProcess patch adds some functions to check whether the proces= s=20 died with a signal. The konsole patch makes use of it in konsole to get rid= =20 display "Session blah exited with signal 2" etc. if applicable. On systems where ECOREDUMP is defined the user is also informed whether the= =20 session dumped core. Any objections/portability issues? BTW, is there some function available to translate signal numbers into thei= r=20 names (and maybe with a short textual description)? Cheers, =2DMalte --Boundary-01=_XUGJ/PwOi4XVE4L Content-Type: text/x-diff; charset="us-ascii"; name="konsole.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="konsole.diff" Index: session.cpp =================================================================== RCS file: /home/kde/kdebase/konsole/konsole/session.cpp,v retrieving revision 1.90 diff -u -3 -d -p -r1.90 session.cpp --- session.cpp 20 Jun 2003 13:04:31 -0000 1.90 +++ session.cpp 27 Jul 2003 23:47:42 -0000 @@ -278,9 +278,19 @@ void TESession::done(int exitStatus) emit updateTitle(); return; } - if (!wantedClose && exitStatus) + if (!wantedClose && (exitStatus || sh->signalled())) { - KNotifyClient::event("Finished", i18n("Session '%1' exited with status %2.").arg(title).arg(exitStatus)); + if (sh->normalExit()) + KNotifyClient::event("Finished", i18n("Session '%1' exited with status %2.").arg(title).arg(exitStatus)); + else if (sh->signalled()) + { + if (sh->coreDumped()) + KNotifyClient::event("Finished", i18n("Session '%1' exited with signal %2 and dumped core.").arg(title).arg(sh->exitSignal())); + else + KNotifyClient::event("Finished", i18n("Session '%1' exited with signal %2.").arg(title).arg(sh->exitSignal())); + } + else + KNotifyClient::event("Finished", i18n("Session '%1' exited unexpectedly.").arg(title)); } emit processExited(); emit done(this); --Boundary-01=_XUGJ/PwOi4XVE4L Content-Type: text/x-diff; charset="us-ascii"; name="kprocess.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kprocess.diff" Index: kprocess.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdecore/kprocess.cpp,v retrieving revision 1.125 diff -u -3 -d -p -r1.125 kprocess.cpp =2D-- kprocess.cpp 16 Jul 2003 20:58:22 -0000 1.125 +++ kprocess.cpp 27 Jul 2003 23:47:37 -0000 @@ -575,12 +575,32 @@ bool KProcess::normalExit() const } =20 =20 +bool KProcess::signalled() const +{ + return (pid_ !=3D 0) && !runs && WIFSIGNALED(status); +} + + +bool KProcess::coreDumped() const +{ +#ifdef WCOREDUMP + return signalled() && WCOREDUMP(status); +#else + return false; +#endif +} + =20 int KProcess::exitStatus() const { return WEXITSTATUS(status); } =20 + +int KProcess::exitSignal() const +{ + return WTERMSIG(status); +} =20 =20 bool KProcess::writeStdin(const char *buffer, int buflen) Index: kprocess.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdecore/kprocess.h,v retrieving revision 1.79 diff -u -3 -d -p -r1.79 kprocess.h =2D-- kprocess.h 16 Jul 2003 20:58:22 -0000 1.79 +++ kprocess.h 27 Jul 2003 23:47:38 -0000 @@ -333,6 +333,27 @@ public: bool normalExit() const; =20 /** + * Checks whether the process was killed by a signal. + * + * @return true if the process has already finished and has not exited + * "voluntarily", ie: it has been killed by a signal. + * + * @since 3.2 + */ + bool signalled() const; + + /** + * Checks whether a killed process dumped core. + * + * @return true if @ref signalled() returns true and the process + * dumped core. Note that on systems that don't define the + * WCOREDUMP macro, the return value is always false. + * + * @since 3.2 + */ + bool coreDumped() const; + + /** * Returns the exit status of the process. * * @return the exit status of the process. Note that this value @@ -340,6 +361,15 @@ public: */ int exitStatus() const; =20 + /** + * Returns the signal the process was killed by. + * + * @return the signal number that caused the process to exit. + * Note that this value is not valid if @ref signalled() returns false. + * + * @since 3.2 + */ + int exitSignal() const; =20 /** * Transmit data to the child process' stdin. --Boundary-01=_XUGJ/PwOi4XVE4L-- --Boundary-03=_bUGJ/+YWKvxBAjx Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA/JGUbVDF3RdLzx4cRAlxuAKCc8YvTjsgV38kycqZs/d5IRf7o3gCfSL9g 4DxQZwyB9y8LQ4oVS1PDBZc= =cbBj -----END PGP SIGNATURE----- --Boundary-03=_bUGJ/+YWKvxBAjx--