ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
I have an application that has a simple command lined interface, which gets command and executes them. Since I try to create a media application, I use the gstreamer framework and I want my interface back after I execute a program.
First I created the interface, the gstreamer framework and combined them. Everything worked perfectly, except that I only get my interface back after a complete run of a file. Here is what I do in short:
"pthread_join (one_thread)" means "Wait until the thread one_thread is finished. Another thing I'm not sure that's clear for you is that when a process ends, it kills all its thread.
So the design of your program will depend on what you want. If you really want to start the play and directly come back to the shell, I think you'd better make simple program (without thread nor fork) and run it with a "&" at the end of your command line, thus the shell will start it as a background job. You can do that into your program with the "fork" function, I don't know if it's really the same thing, but it really look the same, but then your force the "background job" policy, I think it's better that the program user have the choice to start it with or without "&".
I think you misunderstand me a little. My program has an own command line interface, and a & behind the start of my program will give me back the terminal command line.
Do you terminate with pthread_cancel? If so, that doesn't work well with pthread_join except under certain conditions (I'll elaborate if that's the case.) Also, what does the thread do? You didn't specify. Does the main thread continually execute a command in 3b because of looping to 1, or is that jumping to the 1 in the thread? Are you just trying to wait until the command exits? By command, do you mean a new process, or the execution of a function?
ta0kira
1. start program
2. start loop
3a. start thread and start playing a media file --> 1. top of loop
3b execute other command (like pause, mute, help, exit)
4 if other command is not exit, goto 1
5 exit program
After 3a, the program needs to go straight to 2, else a mute command or pause command will be pretty useless.
I am not using pthread_cancel, nor using p_thread_exit().
I found a mistake myself, the call to p_thread_create should be:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.