# Legato api sharing btw 2 Apps causing sysfault

**URL:** <https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445>\
**Category:** Legato Application Framework\
**Created:** [July 16, 2018, 8:44pm UTC](https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445 "2018-07-16T20:44:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mg\_bg](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mg\_bg](https://forum.legato.io/u/mg_bg)\
**Post date:** [July 16, 2018, 8:44pm UTC](https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445/1 "2018-07-16T20:44:58Z")

</div>

So I have created 2 Apps that are sharing a printer.api like in this tutorial:

> **[Extend helloWorld - Legato Docs](https://docs.legato.io/latest/getStartedIPC.html)**
>
> legato™ is an open source Linux-based embedded platform designed to simplify connected IoT application development

everything seems to be working perfectly fine where I define the api in one App and extern it and require it in another App to use it. The issue happens if i stop the App that provides the printer.api, this causes a sysfault on the other App that requires it which triggers a restartApp(which is what i have in my .adef file) which again causes a sysfault which causes the whole mangho green deice to crash and restart/reboot. Now to stop this cycle from happening I have to ssh into device as soon as it is back online and stop the running App else another sysfault will be triggered.

How do I make it that when I stop (or if it crashes) the App that provides the api then by default the other App should stop to prevent sysfault from happening?

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 18, 2018, 1:48am UTC](https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445/2 "2018-07-18T01:48:32Z")

</div>

Hi mg\_bg,

I am trying to simulate with Legato 17.06 sample app helloIpc, and add in printClient.adef:

> faultAction: restartApp

When I stop printServer manually, I can see printClient get killed and restarted.  
But it won’t trigger another sysfault or system reboot.

Would you share Legato logread log or your app/code to check?

Thx

---

<div class="post-metadata">

**Author:** ![mg\_bg](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mg\_bg](https://forum.legato.io/u/mg_bg)\
**Post date:** [July 18, 2018, 3:57pm UTC](https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445/3 "2018-07-18T15:57:23Z")

</div>

@lotam Here are the logs from stoping the server process:

```auto
Jul 18 15:48:18 swi-mdm9x15 user.warn Legato: -WRN- | _appStopClient[2948]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2!
Jul 18 15:48:18 swi-mdm9x15 user.info Legato: INFO | supervisor[510]/supervisor T=main | apps.c DeactivateAppContainer() 340 | Application 'Server' has stopped

```

And couple of seconds after the client process crashes with such logs (Note at this point I changes the faultAction: stopApp)

```auto
Jul 18 15:49:33 swi-mdm9x15 user.debug Legato: DBUG | MyClientComponent[32599]/framework T=main | print_client.c print_Insert() 547 | Sending message to server and waiting for response : 280 bytes sent
Jul 18 15:49:33 swi-mdm9x15 user.warn Legato: -WRN- | MyClientComponent[32599]/framework T=main | LE_FILENAME unixSocket_SendMsg() 479 | sendmsg() failed with errno 32 (Broken pipe).
Jul 18 15:49:33 swi-mdm9x15 user.emerg Legato: *EMR* | MyClientComponent[32599]/framework T=main | print_client.c print_Insert() 550 | Valid response was not received from server
Jul 18 15:49:33 swi-mdm9x15 user.info Legato: INFO | supervisor[510]/supervisor T=main | proc.c proc_SigChildHandler() 1942 | Process 'MyClientComponent' (PID: 32599) has exited with exit code 1.
Jul 18 15:49:33 swi-mdm9x15 user.crit Legato: *CRT* | supervisor[510]/supervisor T=main | app.c app_SigChildHandler() 3250 | Process 'MyClientComponent' in app 'Client' faulted: Stopping app.
Jul 18 15:49:33 swi-mdm9x15 user.info Legato: INFO | supervisor[510]/supervisor T=main | app.c app_Stop() 2731 | Stopping app 'Client'
Jul 18 15:49:33 swi-mdm9x15 user.warn Legato: -WRN- | _appStopClient[3092]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2!
Jul 18 15:49:33 swi-mdm9x15 user.info Legato: INFO | supervisor[510]/supervisor T=main | apps.c DeactivateAppContainer() 340 | Application 'Client' has stopped

```

As you can fault is triggered when the print\_Insert() function is called from client App while Server App is stopped. How does your printClient App behave? If ther is no fault then I would presume it would get killed and restarted over and over and over??

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 18, 2018, 4:54pm UTC](https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445/4 "2018-07-18T16:54:13Z")

</div>

Hi mg\_bg,  
Not sure the print\_Insert() function causing the exception, seems it was added by you?

The test app I am using is sample app comes with Legato framework, /apps/sample/helloIpc:  
[https://github.com/legatoproject/legato-af/tree/master/apps/sample/helloIpc](https://github.com/legatoproject/legato-af/tree/master/apps/sample/helloIpc)

Please have a look.  
Thx

---

<div class="post-metadata">

**Author:** ![mg\_bg](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mg\_bg](https://forum.legato.io/u/mg_bg)\
**Post date:** [July 18, 2018, 5:23pm UTC](https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445/5 "2018-07-18T17:23:01Z")

</div>

Yes I did add the print\_insert function which basically prints and afterward inserts the msg argument into a file. it is different from the sample helloIPC as there it only prints. And Yes I have seen and tried that sample example and noticed that it does stop after I stop the server App, but that is not the case for me which is what is perplexing me.

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)\
**Post date:** [July 19, 2018, 2:46am UTC](https://forum.legato.io/t/legato-api-sharing-btw-2-apps-causing-sysfault/3445/6 "2018-07-19T02:46:03Z")

</div>

Hi mg\_bg,  
Thanks testing the sample app helloIpc, in such case check and debug your app may needed.  
i.e. to find out specific or different in your app compare to helloIpc  
Thx
