Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 18. Files > Reading Standard Error from a Program

Recipe 18.24. Reading Standard Error from a Program

18.24.1. Problem

You want to read the error output from a program; for example, you want to capture the system calls displayed by strace(1) .

18.24.2. Solution

Redirect standard error to standard output by adding 2>&1 to the command line passed to popen( ). Read standard output by opening the pipe in r mode:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint