{"action":"created","issue":{"url":"https://api.github.com/repos/mono/mono/issues/3442","repository_url":"https://api.github.com/repos/mono/mono","labels_url":"https://api.github.com/repos/mono/mono/issues/3442/labels{/name}","comments_url":"https://api.github.com/repos/mono/mono/issues/3442/comments","events_url":"https://api.github.com/repos/mono/mono/issues/3442/events","html_url":"https://github.com/mono/mono/pull/3442","id":172886615,"number":3442,"title":"Add support on Windows to install atexit handler(s) early in console application’s main method.","user":{"login":"lateralusX","id":11529140,"avatar_url":"https://avatars.githubusercontent.com/u/11529140?v=3","gravatar_id":"","url":"https://api.github.com/users/lateralusX","html_url":"https://github.com/lateralusX","followers_url":"https://api.github.com/users/lateralusX/followers","following_url":"https://api.github.com/users/lateralusX/following{/other_user}","gists_url":"https://api.github.com/users/lateralusX/gists{/gist_id}","starred_url":"https://api.github.com/users/lateralusX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lateralusX/subscriptions","organizations_url":"https://api.github.com/users/lateralusX/orgs","repos_url":"https://api.github.com/users/lateralusX/repos","events_url":"https://api.github.com/users/lateralusX/events{/privacy}","received_events_url":"https://api.github.com/users/lateralusX/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mono/mono/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-08-24T07:49:11Z","updated_at":"2016-10-11T15:56:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mono/mono/pulls/3442","html_url":"https://github.com/mono/mono/pull/3442","diff_url":"https://github.com/mono/mono/pull/3442.diff","patch_url":"https://github.com/mono/mono/pull/3442.patch"},"body":"Add support on Windows to install atexit handler(s) early in application’s startup.\r\n\r\nThis is done by adding a new argument to install specific named custom handlers, --handlers=. There is also an argument to describe the supported handlers on current platform, --help-handlers.\r\n\r\nThe supported handlers can be different depending on implementing platform and currently only Windows uses this feature to install an atexit handler waiting for a keypress before exiting process. This is however a generic concept that could be used to run handler code early in the boot process on any platform for other purposes. Adding the argument first in command line makes it possible to do the installation very early in the boot process, this is used by the waitkeypress atexit handler in order to be used in cases where the arguments itself are unsupported or incorrect formatted causing an exit of the process.\r\n\r\nWhen running under Visual Studio debugger the console window will not be kept open when the debugee process terminates. Normally this is not a problem, but there are scenarios, especially when having errors in configuration, when you would like the console to be kept open so you can read the output in order to detect the error.\r\n\r\nNormally there is an option to start the console application from within Visual Studio but not attaching the debugger (CTRL+F5) and by default Visual Studio will then inject a pause in the execution of the process holding up the console, but for some reasons, having more complex solutions like mono, this feature stops working, so it is not possible to keep the console open in that scenario for more complex solutions.\r\n\r\nThis makes it a little problematic to hold the process when working within the debugger in order to look for console output and errors. Since mono can exit the process using exit command and not only by returning from main, the developer needs to set breakpoints on both end of main and in c-runtime exit methods. Even if that is a possible workaround this option won't work when running the process outside the debugger (CTRL+F5).\r\n\r\nThis commit adds a handler argument that can be used on Windows (potential on other platforms as well), atexit-waitkeypress.\r\n\r\nThe waitkeypress will hold the console and process open until a key is pressed and is very useful when running and debugging mono from within Visual Studio. Example of output when running mono’s mono-mini-regression-test with an assembly not found together with –handlers=atexit-waitkeypress command line argument:\r\n\r\nfailed to load assembly: gshared-nofound.exe\r\nOverall results: tests: 0, 100% pass, opt combinations: 25\r\nPress any key to continue . . .\r\n\r\nCurrently this is only implemented for Windows, but could be enabled for other platforms, if similar need exist elsewhere.\r\n\r\nSince this is a standard mono command line option it is possible to inject it using the MONO_ENV_OPTIONS environment variable as well."},"comment":{"url":"https://api.github.com/repos/mono/mono/issues/comments/252960412","html_url":"https://github.com/mono/mono/pull/3442#issuecomment-252960412","issue_url":"https://api.github.com/repos/mono/mono/issues/3442","id":252960412,"user":{"login":"lateralusX","id":11529140,"avatar_url":"https://avatars.githubusercontent.com/u/11529140?v=3","gravatar_id":"","url":"https://api.github.com/users/lateralusX","html_url":"https://github.com/lateralusX","followers_url":"https://api.github.com/users/lateralusX/followers","following_url":"https://api.github.com/users/lateralusX/following{/other_user}","gists_url":"https://api.github.com/users/lateralusX/gists{/gist_id}","starred_url":"https://api.github.com/users/lateralusX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lateralusX/subscriptions","organizations_url":"https://api.github.com/users/lateralusX/orgs","repos_url":"https://api.github.com/users/lateralusX/repos","events_url":"https://api.github.com/users/lateralusX/events{/privacy}","received_events_url":"https://api.github.com/users/lateralusX/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T15:56:12Z","updated_at":"2016-10-11T15:56:12Z","body":"Change OK to merge?"}}
{"actor":{"display_login":"lateralusX"}}