Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [SOLVED] Need help here! prevent terminal from closing!

    Hi all, I'm new to solaris and i have some problem.. hope you guys can help me out.

    Currently i'm doing a script for my project and I want to prevent people from exiting the terminal by clicking the "X" at the top right.
    so in short:

    when I run the script,
    user cannot exit out of the terminal
    unless the scipt finish running.

    Thanks alot !

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    As far as I know, you can't - it would depend upon the terminal window program that is running your shell. I know that the KDE kconsole program doesn't allow disabling the "close window" button under any circumstances. That said, you can do this in an X11 program by intercepting the close-window event. So, it comes down to whether or not you want to write your own X-term program that will handle this scenario. I think that is likely what you would have to do.

    Anyway, maybe some other lurker here knows how to do what you want without a lot of custom C or C++ coding...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Thanks for the reply,

    but just to add on,

    I'm using bash for for this project and i heard from someone form other forum saying that trap SIGHUPs works... but i not sure how he did it.

  4. $spacer_open
  5. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    There is definitely no way to do this. Even if it was possible for a particular terminal (that was, for some reason using something SIGHUP to kill processes), there is no guarantee that it would work for others.

    I suspect that every terminal uses SIGKILL or SIGSTOP to kill its child processes, and these cannot be ignored by a process.

    You can always disassociate your process from the terminal by making it a daemon, and that way it could run until it finishes, no matter what the user does.

  6. #5
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    The Netherlands
    What is it exactly that you are trying to do? Because the way I see it, you start with asking how to develop a certain solution that is going to be, if not difficult then very difficult. Perhaps there is another solution that is much easier to achieve...

    Let's look at the problem first because in most instances the running of a script should not depend on the openness of a terminal window or users repressing the urge to click an X
    Can't tell an OS by it's GUI

  7. #6
    Thanks for replying ppl!
    I have found the solution to the problem already!
    Again... Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts