{"id":5237,"date":"2014-03-30T19:58:58","date_gmt":"2014-03-30T19:58:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-write-to-stderr-with-writefile-collection-of-common-programming-errors\/"},"modified":"2014-03-30T19:58:58","modified_gmt":"2014-03-30T19:58:58","slug":"how-to-write-to-stderr-with-writefile-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-write-to-stderr-with-writefile-collection-of-common-programming-errors\/","title":{"rendered":"How to write to stderr with WriteFile-Collection of common programming errors"},"content":{"rendered":"<p>Is it possible to get <code>HANDLE<\/code> referring to standard error output that could be written with <code>WriteFile<\/code> on Windows?<\/p>\n<p>The reason I am asking is that I am writing some logging utilities for me. And I am trying to give the data directly to system to:<\/p>\n<ul>\n<li>avoid any potential problems with things not being flushed and<\/li>\n<li>let the system interleave messages from separate threads without need for locking (if that actually works is the other question).<\/li>\n<\/ul>\n<p>The application is otherwise windows subsystem, so it should only write anywhere if the application actually inherited standard error? If that&#8217;s possible, that is.<\/p>\n<p>NOTE: I already have log sink to <code>OutputDebugString<\/code>. And it&#8217;s equivalents for several other platforms. And to file, which uses low-level API to avoid any additional buffering (as the message is already assembled in on-stack buffer and needs to be flushed immediately). And I just want to reuse the code for writing file for writing on standard error too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Is it possible to get HANDLE referring to standard error output that could be written with WriteFile on Windows? The reason I am asking is that I am writing some logging utilities for me. And I am trying to give the data directly to system to: avoid any potential problems with things not being flushed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5237","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5237"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5237\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}