Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Show exactly the commands that you issue.
Show the line(s) in the bash script executing your program.
Show terminal output.
Run your script with bash -x /path/to/script and copy relevant output here.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Rep:
So you wrote coproc to prompt for user input? Or just to wait for user input? You didn't really respond to jlinkels requests. Maybe you could rewrite the script so it prompts for user input. I'm still not clear on what the problem is.
What you're showing on the command line is not what's in the bash script...
...and nothing you've posted has anything to do with running in background...running in a script is not running in background.
So, I'm a tad confused about what your problem actually is...
To run the command in a script, put the command in the script. i.e.:
Code:
#!/bin/bash
coproc nfcDemoApp poll
I'm ignoring the bit about "background" here...
But I'm just trying to take it one step at a time to build the script. The most important thing is to run nfcDemoApp as a daemon.
I'm investigating the nfcDemoApp source code (developed by NXP) and this software apparently cannot be detached by the shell. The software takes input data from i2c (treating it like a keyboard or other input device) and when I tried to run the coproc command inside a script, I assume the software does not detect the input and closes because of that.
Quote:
Originally Posted by MadeInGermany
Cut the default file handles and send to background
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
I might be totally on the wrong track, but when nfcDemoApp is called from a script, it is the child process of that script, isn't it? So the script runs, calls coproc. Coproc executes nfcDemoApp, backgrounds it and then returns to the calling script. The calling script terminates and kills all its child processes. Which is nfcDemoApp.
I.e. backgrounding does not disconnect the background program from the calling script. It is just backgrounded, which means stdin and stdout are disconnected from the keyboard and terminal.
If you start and background a program in the shell, and then close the shell. The backgrounded program will be closed as well.
Running from the shell, you can disown the backgrounded program. Then it continues to run. You can also start the program with nohup. Although I am not sure it continues when the script terminates. It continues when you close your shell.
I am totally not sure how all this works with coproc.
Summarizing, this should be working from withing a script.
Distribution: Debian Jessie, Elementary Loki... in the past: Gentoo, Slackware, Suse
Posts: 8
Original Poster
Rep:
Jlinkels, sorry for answer you today.
Quote:
Originally Posted by jlinkels
I might be totally on the wrong track, but when nfcDemoApp is called from a script, it is the child process of that script, isn't it? So the script runs, calls coproc. Coproc executes nfcDemoApp, backgrounds it and then returns to the calling script. The calling script terminates and kills all its child processes. Which is nfcDemoApp.
Yes, you are right. Although, I tried everything: coproc, nohup as well disown. All these things didn't work.
Opening a new terminal after boot, doing automatic login and execute the software works. Yes, that is a poor solution, but was the unique alternative.
what I don't understand: you need to check the logs of that app, why it was died (if available).
If I understand well it runs from a terminal, but won't run without terminal. That is expected if user input was required, but no tty attached to the process.
Distribution: Debian Jessie, Elementary Loki... in the past: Gentoo, Slackware, Suse
Posts: 8
Original Poster
Rep:
Quote:
Originally Posted by pan64
what I don't understand: you need to check the logs of that app, why it was died (if available).
If I understand well it runs from a terminal, but won't run without terminal. That is expected if user input was required, but no tty attached to the process.
pan64,
The app must be in continuous looping and never die.
The software runs without terminal but only if I type "coproc nfcDemoApp" in shell even I close the terminal after... It's weird.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.