![]() |
|
#1
|
|||
|
|||
Help on setsid() [Only for UNIX/Linux users]Hi,
I'm a C newbie and doing my own shell prompt. I need a way to execute commands in a new seesion (window). I was told this could be done using setsid(). Here's my first attempt, the output should be a new window with date printed: CPP / C++ / C Code:
Apparently, I got an error in UNIX : Not Owner 1) Is there anthing that I did wrong ? 2) Is there any other way that I can exec commands in a new window? Thanks. |
|
#2
|
||||
|
||||
|
Hi nusstu.
Maybe you can clarify exactly what you mean by "exec commands in a new window" Do you mean that you want to pull up a new terminal window? I really don't think that setsid is going to do you a whole lot of good. From my limited understanding it will fail every time in the function that you have written, because your function is the "group leader" and so the PID that is being attempted to be returned is the PID of your function. This results in an error. Here is a quote from the man page: Quote:
The key portion is "if the calling process is not a process group leader". Here is a bash script that I use to spawn a terminal session (using konsole) that you could call using the system command: Code:
This will draw a seperate terminal window with the title set to Raven Konsole. Not sure if this helps or not, but if you give us more of an idea of what it is you want to accomplish, we may be able to help you out more. Good Luck! d |
|
#3
|
|||
|
|||
|
Hi dsmith,
Yes I wanna pull up a new window, what i wanna do is simply run the /bin/date command in a new window from a C file. So the 1st window runs main and the 2nd displays date. Is that possible to do in C? I think ur script file isn't what i'm looking for I want to open a new window from a C file. "The calling process is the leader of the new session, the process group leader of the new process group, and has no controlling tty" What's a process group leader, and what does controlling tty mean? Thanks. |
|
#4
|
||||
|
||||
|
It sounds like you want to be able to run these concurrently? This is really simple if you want the parent process to wait for the child process to complete (system()), but what you want is probably more like (pthread_create()). I don't have alot of experience here, but if you have access to the man pages, pull up the man page for pthread_create.
Quote:
The problem with the exec family of processes is that it replaces your current process: Quote:
I don't think that is what you want either. The only thing I found that came close to doing what your are taking about is pthread_create, which may or may not be linux specific. Sorry, I can't be of more help. |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The