title: What causes runtime error message: std::system_error - operation not permitted, including mult-threading?
body: <p><strong>Update in 2022</strong></p>
  <p>C++ 17 &amp; 20 now have built in support for multithreading in the standard library. I would suggest using these rather than using the Linux specific pthread library.</p>
  <p><strong>Original Question</strong></p>
  <p>I wrote a program to test threads on 64 bit kubuntu linux, version 13.04. Actually I robbed the code from someone else who was writing a test program.</p>
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;thread&gt;
  
  void task1(const std::string msg)
  {
      std::cout &lt;&lt; &quot;task1 says: &quot; &lt;&lt; msg &lt;&lt; std::endl;
  }
  
  int main(int argc, char **argv)
  {
      std::thread t1(task1, &quot;Hello&quot;);
      t1.join();
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  <p>I compiled using:</p>
  <pre><code>g++ -pthread -std=c++11 -c main.cpp
  g++ main.o -o main.out
  </code></pre>
  <p>Then ran:</p>
  <pre><code>./main.out
  </code></pre>
  <p>As an aside, when I 'ls -l', main.out shows up in in green text like all executables, but also has an asterisk at the end of its name. Why is this?</p>
  <p>Back to the problem in hand: When I ran main.out, an error appeared, which said:</p>
  <pre><code>terminate called after throwing an instance of 'std::system_error'
    what():  Operation not permitted
  Aborted (core dumped)
  </code></pre>
  <p>Anyone any ideas on how to fix this?</p>