sugarlabs / sugar

Sugar GTK shell
GNU General Public License v3.0
255 stars 242 forks source link

/usr/bin/sugar does not exit if window is closed #952

Open quozl opened 2 years ago

quozl commented 2 years ago

Running /usr/bin/sugar from a GNOME Terminal under X11 is not something we had planned, but if it is done and the window is closed, Sugar does not exit.

sarthak0527 commented 2 years ago

I would like to work on this issue.

chimosky commented 2 years ago

@sarthak0527 feel free to open a PR when you have one.

sarthak0527 commented 2 years ago

I'm new to open source , could you guide me how can I solve this issue ?

quozl commented 2 years ago

Not really, if we knew how to solve the issue we would just go ahead and do so.

chimosky commented 2 years ago

@sarthak0527 a great place to start would be reproducing the issue, you'll have to run it from GNOME though. You'll need to have sugar installed before you run the command above in your terminal.

sarthak0527 commented 2 years ago

@chimosky I have installed the sugar . Now what should I do next?

quozl commented 2 years ago

The issue is;

Running /usr/bin/sugar from a GNOME Terminal is not something we had planned, but if it is done and the window is closed, Sugar does not exit.

Have you run GNOME Terminal?

When GNOME Terminal is running, have you run /usr/bin/sugar?

When the Sugar window is closed, what do you observe about the Sugar process?

sarthak0527 commented 2 years ago

I did run GNOME Terminal.

After running /usr/bin/sugar , it is running but in system monitor it is not showing .

Also when the sugar window is closed ,I oberserve nothing about the process.

quozl commented 2 years ago

System monitor does not show all processes. The shell command sudo ps ax may be helpful for listing all processes.

When you say you observe nothing about the process, what do you mean? Does the process exit, or is it still running as described in this issue? You have to be familiar with Linux process creation and termination to be able to detect this issue.

solo-daemon commented 1 year ago

@quozl i would like to work on this

quozl commented 1 year ago

My commiserations to you. Good luck!

DaffyTheDuck commented 1 year ago

Hi there! May I know what was the expected output ?

quozl commented 1 year ago

/usr/bin/sugar is a shell script derived from bin/sugar.in, and generates quite a lot of output in various places. The output it generates is not the concern in this issue, it is that the processes run by the shell script do not terminate when an enclosing GNOME Terminal is closed.

DaffyTheDuck commented 1 year ago

/usr/bin/sugar is a shell script derived from bin/sugar.in, and generates quite a lot of output in various places. The output it generates is not the concern in this issue, it is that the processes run by the shell script do not terminate when an enclosing GNOME Terminal is closed.

Hmm! as I ran this command in my terminal, I noticed that it changed my cursor style and replaced it with the one in sugar environment, also in the output of ps ax I see no process of sugar running. Also it keeps the cursor in the same way even the terminal is closed! as i've little experience in linux and it's processes, i would love it if you enlighten me more on this šŸ˜„

quozl commented 1 year ago

Yes, that's right.

Sugar was never intended to be run from any terminal, but rather as an X windows session manager, or the .xsession file. Sugar does work properly when run in that way.

All logs are kept in .sugar/default/logs and that's where you can look for an explanation of why Sugar terminated early.

Changing cursor is one of the steps of Sugar startup (src/jarab/main.py search for cursor-theme), and there is code to put it back the way it was if Sugar is exited normally.

So given your description I'd say Sugar failed to start, and the explanation will be in the logs. That isn't what happened in this issue though.

bhavyabansal9068 commented 1 year ago

@chimosky @quozl Hello team,

Please guide me based on my analysis on this issue. I have investigated the issue and have come to the conclusion that the problem lies in the sugar/src/jarabe/main.py file. Specifically, the "_start_window_manager()" function is being called internally and is changing the cursor of the virtual machine without performing verification.

image

This is why no processes appear to be running even after closing the GNOME terminal but cursor is changed. Upon reviewing the logs, I also noticed that when we trigger Sugar from GNOME terminal, it fails because screen 0 is already in use. However, the root cause of this issue is the cursor change in the code.

image

To resolve this issue, we could change the cursor only after verifying whether our screen is already in use or not. To further improve these kinds of issue we could use proper error handling (Try and Except Block). I would be happy to contribute more to Sugarlabs.

Best regards, Bhavya Bansal

quozl commented 1 year ago

G'day, and thanks for your input. The problem described is that the process does not exit. The process does continue running. If you think that changing the cursor theme has anything to do with it, then please do test and let us know your result, either here or as a pull request. As for me, I don't see how the cursor theme can cause a process not to exit. I was puzzled as to why you brought it up, then I remembered someone mentioned it. Don't be distracted by comments unrelated to the issue.

Please, in future copy and paste messages or code into the issue rather than use screenshots; your screenshots are (a) not read by a screenreader, (b) not searchable, (c) not visible when reading mail using mutt or high security mail readers. See Creating and highlighting code blocks.

I've checked the mailing list pending administrative actions and there are none. I've checked and your mail address bhavyabansal4321@gmail.com is not subscribed. Please do subscribe.

bhavyabansal9068 commented 1 year ago

Thanks for guiding @quozl . I have attached the error logs that we are getting after running Sugar from the GNOME terminal.

(main.py:3327): Wnck-WARNING **: 08:54:39.331: libwnck is designed to work in X11 only, no valid display found

(metacity:3334): metacity-WARNING **: 08:54:39.359: Option ā€œ--no-compositeā€ is deprecated, use the ā€œ--compositorā€ instead.
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/jarabe/main.py", line 380, in <module>
    main()
  File "/usr/lib/python3/dist-packages/jarabe/main.py", line 347, in main
    _start_window_manager()
  File "/usr/lib/python3/dist-packages/jarabe/main.py", line 208, in _start_window_manager
    screen.connect('window-manager-changed', __window_manager_changed_cb)
AttributeError: 'NoneType' object has no attribute 'connect'

(metacity:3334): metacity-WARNING **: 08:54:40.261: Screen 0 on display ":0" already has a window manager; try using the --replace option to replace the current window manager.

So, what I am thinking is, if we could add a validation check at the beginning of our main code to determine whether the screen is a window manager or not, it might help. Right? This way, before executing any process or job, our code will stop its execution."

quozl commented 1 year ago

That's a problem, but it's not this issue. I don't want to talk about it here in this issue. Please take it to another issue or better yet make a pull request to fix it.

bhavyabansal9068 commented 1 year ago

@quozl Raised PR, Please Review.

quozl commented 1 year ago

As a data point, the Logout option does terminate the Sugar process on 0.118 on Debian 11 Bullseye.