DrSpin Mu-sings

June 20, 2016

DRX499 – WORKAROUND FOR USERS TO CLEAN UP HANGING TOPSPIN PROCESSES

REQUIREMENT  :

  • When user authenticates, the window manager i.e. desktop session should start the Topspin software automatically
  • Once the user completes Topspin session, when the application is closed by the user, a suitable trigger should end the desktop session gracefully i.e. ensure that there are no hanging threads from the parent Topspin process
  • In the eventuality that such threads are still lying around,  an adminstrator level script cleans up these threads.
  • As an ideal followup,  the normal user herself/himself can terminate these threads and start Topspin, even if the said threads belong to any other uid or orphaned to root.

IMPLEMENTATION :

  • We have two scripts that run under the Autostart feature of gnome desktop session.  These are called  : ~/.config/autostart/topspin.desktop and ~/.config/autostart/topsense.desktop
    • topspin.desktop launches /opt/topspin/prog/bin/scripts/topspin
    • topsesnse.desktop  launhces the script /opt/topsense.sh . The listing of topsense.sh is as follows :
    • Topsense.sh
    • Topsense.sh first while loop wait for the application to launch.  Once it detects the parent thread, it descends into another while loop that wait for this parent thread to terminate.   When a user closes the topspin actively,  the second trigger occurs and the desktop session is terminated.   This aggressive form of sensing the presence of topspin thread was necessitated by our previous experience, where simply confirming the absence of any topspin threads as an after fact, before closing the desktop session did not always work reliably.   One possible cause  was that the ‘cpr’ and it’s child threads took quite long to terminate and therefore our earlier script (TSkill)  ended the desktop sessions prematurely, with the threads still lying around.  This leads to the child processes being transferred to the PPID of 0  and this means that only the superuser can come in and send SIGKILL to terminate these threads.
    • In the current version,  the while loop mitigates this to an extent,  such that, unless the threads are cleared, the desktop session is not closed.