# Cannot call any Legato services API from a legato thread

**URL:** https://forum.legato.io/t/cannot-call-any-legato-services-api-from-a-legato-thread/207
**Category:** Legato Application Framework
**Created:** [February 29, 2016, 6:15pm UTC](https://forum.legato.io/t/cannot-call-any-legato-services-api-from-a-legato-thread/207 "2016-02-29T18:15:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![antcalo](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@antcalo](https://forum.legato.io/u/antcalo)
#### Post date: [February 29, 2016, 6:15pm UTC](https://forum.legato.io/t/cannot-call-any-legato-services-api-from-a-legato-thread/207/1 "2016-02-29T18:15:05Z")

</div>

Hi All

I’m getting stucked into a strange issue on legato 15.12.1.beta: I’ve created a simple helloworld application that in the main call the le\_result\_t le\_pos\_Get3DLocation(…).

It used to work but when I try to call the same api from a legato thread insteadm, the applciation exit with Code1.

If I remove the legato API le\_pos\_Get3DLocation and just keep the legato thread running (a simple loop with 5 second sleep and some logs) it works without any issue, so the legasto threads are ok, but when I try to call a legato api inside I got this (my\_sms\_loop is a print of the thread function):  
Thank you in advacne for your help!

[pid 2844] writev(12, [{“DUH\1\1 \0\0”, 8}, {“5\37\0CECU1\0&\305YA\3SdkCmco\0”, 22}, {“\0\2\0\0\f\0my\_sms\_loop\0\0\2\0\0\r\0in the l”…, 45}], 3) = 75  
[pid 2844] gettimeofday({1456768501, 914907}, NULL) = 0  
[pid 2844] send(3, “\<8\>Feb 29 17:55:01 Legato: _EMR_”…, 180, MSG\_NOSIGNAL) = 180  
[pid 2844] clock\_gettime(CLOCK\_MONOTONIC, {254, 94884777}) = 0  
[pid 2844] clock\_gettime(CLOCK\_MONOTONIC, {254, 96471836}) = 0  
[pid 2844] writev(12, [{“DUH\1\3\0\0\0”, 8}, {“SdkC\27\v\0\0”, 8}], 2) = 16  
[pid 2844] tgkill(2839, 2841, SIGRTMIN) = 0  
[pid 2844] futex(0xb6a564b8, FUTEX\_WAIT, 2841, NULL \<unfinished …\>  
[pid 2841] \<… read resumed\> 0x408078, 10024) = ? ERESTARTSYS (To be restarted if SA\_RESTART is set)  
[pid 2841] — SIGRTMIN {si\_signo=SIGRTMIN, si\_code=SI\_TKILL, si\_pid=2839, si\_uid=0} —  
[pid 2841] madvise(0xb6257000, 8364032, MADV\_DONTNEED) = 0  
[pid 2841] exit(0) = ?  
[pid 2844] \<… futex resumed\> ) = 0  
[pid 2844] tgkill(2839, 2842, SIGRTMIN) = 0  
[pid 2844] futex(0xb62564b8, FUTEX\_WAIT, 2842, NULL \<unfinished …\>  
[pid 2842] \<… futex resumed\> ) = ? ERESTARTSYS (To be restarted if SA\_RESTART is set)  
[pid 2842] — SIGRTMIN {si\_signo=SIGRTMIN, si\_code=SI\_TKILL, si\_pid=2839, si\_uid=0} —  
[pid 2842] futex(0xb6c8292c, FUTEX\_WAKE\_PRIVATE, 2147483647) = 0  
[pid 2842] madvise(0xb5a57000, 8364032, MADV\_DONTNEED) = 0  
[pid 2842] exit(0) = ?  
[pid 2844] \<… futex resumed\> ) = 0  
[pid 2844] close(11) = 0  
[pid 2844] unlink(“/var/dltpipes/dlt2839”) = 0  
[pid 2844] close(12) = 0  
[pid 2844] close(-1) = -1 EBADF (Bad file descriptor)  
[pid 2844] close(-1) = -1 EBADF (Bad file descriptor)  
[pid 2844] mq\_unlink(“dlt\_message\_queue.2839”) = -1 ENOENT (No such file or directory)  
[pid 2844] exit\_group(1) = ?  
[pid 2849] +++ exited with 1 +++  
[pid 2848] +++ exited with 1 +++  
[pid 2847] +++ exited with 1 +++  
[pid 2843] +++ exited with 1 +++  
[pid 2842] +++ exited with 1 +++  
[pid 2841] +++ exited with 1 +++  
[pid 2844] +++ exited with 1 +++

---

<div class="post-metadata">

### Author: ![amitchell](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/amitchell/32/68_2.png) [@amitchell](https://forum.legato.io/u/amitchell)
#### Post date: [March 8, 2016, 10:07pm UTC](https://forum.legato.io/t/cannot-call-any-legato-services-api-from-a-legato-thread/207/2 "2016-03-08T22:07:11Z")

</div>

Hi.

Can you post some code that will allow us to reproduce the issue?

Thanks.
