android dupped stderr workaround

Avoid using dupped stderr, since
http://git-annex.branchable.com/bugs/warning_-_WebApp_crashed:___60__file_descriptor_15__62__:_hPutStr:_illegal_operation___40__handle_is_closed__41___on_Android/#comment-a24c73803fb10bd35afdc10d50e071c8
seems to involve that handle not being dupped originally, or perhaps
getting closed when the web browser is started on Android.

Using the dupped stdout is known to work before starting the web browser,
so it should work after -- unless perhaps starting it closes both handles.

In any case, there's no real need to write to stderr here.
This commit is contained in:
Joey Hess 2013-05-30 13:55:22 -04:00
parent f3888c272d
commit 4cc803c733

View file

@ -164,7 +164,7 @@ openBrowser mcmd htmlshim realurl outh errh = do
{- The Android app has a menu item that opens this file. -} {- The Android app has a menu item that opens this file. -}
writeFile "/sdcard/git-annex.home/.git-annex-url" realurl writeFile "/sdcard/git-annex.home/.git-annex-url" realurl
#endif #endif
hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url toconsole $ "Launching web browser on " ++ url
hFlush stdout hFlush stdout
environ <- cleanEnvironment environ <- cleanEnvironment
(_, _, _, pid) <- createProcess p (_, _, _, pid) <- createProcess p
@ -174,11 +174,12 @@ openBrowser mcmd htmlshim realurl outh errh = do
} }
exitcode <- waitForProcess pid exitcode <- waitForProcess pid
unless (exitcode == ExitSuccess) $ do unless (exitcode == ExitSuccess) $ do
hPutStrLn (fromMaybe stderr errh) "failed to start web browser" toconsole "failed to start web browser"
#ifdef __ANDROID__ #ifdef __ANDROID__
hPutStrLn (fromMaybe stderr errh) "To open the WebApp, go to the menu and select \"Open WebApp\"" toconsole "To open the WebApp, go to the menu and select \"Open WebApp\""
#endif #endif
where where
toconsole = hPutStrLn (fromMaybe stdout outh)
p = case mcmd of p = case mcmd of
Just cmd -> proc cmd [htmlshim] Just cmd -> proc cmd [htmlshim]
Nothing -> browserProc url Nothing -> browserProc url