Run my application at startup from an Embedded image

Hi.

I’m building an embedded image of my QNX system in a compact flash. I’ve done the script and everything is correct, except that I want to run my application at startup.

This is part of my script:

[code][virtual=x86,bios +compress] .bootstrap = {
startup-bios
PATH=/proc/boot:/bin:/usr/bin LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/
dll procnto
}

[+script] .script = {
(…)

3 consoles

    devc-con -n3 &
    reopen /dev/con1

(…)

Start the main shell

    display_msg Starting Main Shell
    waitfor /dev/con2
    tinit

}
(…)
/etc/config/ttys={
con1 “/bin/sh” qansi on
con2 “/bin/sh” qansi on
}
(…)

Place our application in /opt/app

embedded_image_path=QNX_path

/opt/app=/root/dario/altogether/debug
[/code]

Currently I’m using tinit to start two sh shells in the first two consoles. So, I can start my application manually. But I want to do it automatically at startup.

If I run the application in the third console via the script:

[+script] .script = {
(...)
# 3 consoles
        devc-con -n3 &
        reopen /dev/con1
(...)
        reopen /dev/con3
        /opt/app/bin/held &
# Start the main shell
        display_msg Starting Main Shell
        waitfor /dev/con2
        tinit
}

then, if I close the application (or it dies), the third console dies forever.

If I run it via tinit:

[+script] .script = {
(...)
# 3 consoles
        devc-con -n3 &
        reopen /dev/con1
(...)
# Start the main shell
        display_msg Starting Main Shell
        waitfor /dev/con2
        tinit
}
(...)
/etc/config/ttys={
con1 "/bin/sh" qansi on
con2 "/bin/sh" qansi on
con3 "/bin/sh -c /opt/app/bin/held" qansi on
}
(...)

every time the application dies (or it’s closed), the sh -c /opt/app/bin/held makes it run again. It’s impossible to kill it completely.

If I run the shells with ‘sh -l’ in tinit and the $HOME/.profile contains

#!/bin/sh if [ `ps -A | grep -c held` -eq 0 ] ; then echo "held not currently running. Let's run it /opt/app/bin/held fi

The application runs every time I enter a shell and it’s not already running.

The thing I want is an intermediate solution. I want it to run at startup, only, and if I close it or it dies, I want it to return a shell.

How can I do it?

Thanks a lot,

Dar

You can try this:

In your Image - at the end - put this code:
[i]

prompt login and message on second console

reopen /dev/con2
display_msg " local shell"
[pri=25 +session] esh -c /etc/loginwatch.sh &

System is running - start the main shell and app

reopen /dev/con1
[+session] esh -c ./usr/app/myapp &[/i]

The loginwatch.sh looks like:


while true;
do
/bin/login -p
done

This have the effekt, that evertyime you kill / or exit from a shell, it will be start again.

Maybe this works - or is an idea - I use this, for my app!

The loginwatch.sh should be amended:

/path_to_your_app/your_app
while true;
do
/bin/login -p
done

This has the desired effect in that it runs the application once at startup, since the loginwatch.sh is started from the init script as shown, and when your app returns for whatever reason it enters the endless loop with the shells (/bin/login -p could be equally /bin/sh) and will never run your app again.

Regards,
Albrecht