dde / qqcs

Quick Quantum Circuit Simulation
Other
1 stars 5 forks source link

[unitaryHACK] exit-issue discussion on qdesk_interactive.js [WIP] #22

Closed vanzilar closed 3 years ago

vanzilar commented 3 years ago

[unitaryHACK] I am truly amazed at this :sparkles:quantum:sparkles: software.

As I was trying it out, when I hit CTRL-C CTRL-Z or CTRL-D I thought it would stop and exit the program so I could swap to other projects however it did not and would just continue looking for input.

To test I added an exit command into the qdesk_interactive.js code and found it did as I expected (see exit-issue branch). However I am unsure if I am fixing a bug or changing a desirable feature.

If qcss is already working by design when we stop a process with CTRL-C, is there another way to exit the program I am unaware of? If not, may I create an exit command by perhaps adding a "quit" or "exit" command to the qcss command line?

I would really appreciate any feedback at all. :pray:

Just so you are aware this pull has a 2nd purpose. It is allowing myself to become more familiar with git and the git pull process itself as I examine the other [unitaryHACK] issues and choose which of the remaining ones to pursue.

Thanks for reading and hope to chat more in the future. :bow:

dde commented 3 years ago

Interesting issue. I ran this when I saw your issue and had no problem, although when I moved to a Windows machine, I did have the problem. Then I realized my OS X system was node v12.16.1, and the Windows system was newly installed. I upgraded node on OS X to 16.2.0, and the problem occurred. Although your exit() solution is perfectly reasonable, the original design relied on the design of node's process module which terminates when it no longer has work to do. At line 82, when ctrl-C or ctrl-D was recognized, the 'end' event is emitted on stdin. I'm guessing that in earlier versions, this caused stdin to cleanup any event handlers, then node had nothing to do and terminated. When I saw the behavior in the latest version, it was clear that the 'readable' event handler was still active. I changed line 85 from continue to break, which caused the 'readable' handler to return. This also solved the problem. I prefer this change as it allows anything else which may be in progress to continue executing (there is currently nothing in that category, but there may be in the future). I will close this issue and make the mod to line 82. Thanks for noting this problem.