Solving “getaddrinfo() thread failed to start”

Curl-logoIf you download files onto your system using PHP, Yum, RPM, or other tools, there’s a good chance curl is involved, be it part of a library (such as PHP’s curl extension and the Guzzle HTTP client) or called on its own.

The version of curl provided in IBM i PASE uses multiple threads to speed up common tasks such as DNS lookups. When threading support is not available, however, curl fails.

Threads are disabled by default in QSH sessions and batch jobs, and never supported in QP2SHELL. If threads are not enabled when you use curl, you’ll get messages like:

Don’t worry! Nothing’s wrong with curl or your code. You just need to allow multi-threading in your job. Here are options to enable multi-threading:

  • Use SSH or QP2TERM, which enable threads by default.
  • If you use QSH, set the environment variable QIBM_MULTI_THREADED to Y before starting any program that runs curl. This can be done at whatever scope you feel is appropriate; for example, it can be put in a shell (interactively or in a script) before you start the program.
  • Alternatively, start the job with the ALWMLTTHD parameter set to *YES.

After you do this, curl shouldn’t have any problems.

This post was based on the curl documentation for IBM i-specific notes.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.