Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to attach an xterm to a process/thread ? Post 302170384 by RipClaw on Monday 25th of February 2008 12:22:35 PM
Old 02-25-2008
Hammer & Screwdriver

Well, I got it working.
We have to use the file descriptor returned by ptsname() for reading & writing.
and the xterm's -Sccn option holds good only when it is invoked from within a process with a system() call.
 

10 More Discussions You Might Find Interesting

1. Programming

List of Thread IDs of a process

Hello, Can some one tell how to read the thread IDs of the current process in Sun Solaris. Any help will be appreciated. regards, Murali (0 Replies)
Discussion started by: hmurali
0 Replies

2. Shell Programming and Scripting

get Thread information from process

Hello all im trying to build small script in tcsh that will monitor some process that are making some api calles to some server . first of all im trying to find way to see how many threads each process is using , and else how can i print each Thread id . can it be done ? ( using sunOs ) (2 Replies)
Discussion started by: umen
2 Replies

3. Shell Programming and Scripting

[BASH] xclock/xcalc/xterm...process question?

I have no idea how to do this: Let's say the user opens an "xclock &" in one of my scripts and I don't want him to be able to re-open one with the script. How could I test that? Possibly with a message saying that "The <xclock(or w/e other process like xcalc)> is already running in the... (3 Replies)
Discussion started by: Yakuzan
3 Replies

4. UNIX for Advanced & Expert Users

attach process from another ssh session

Hi, I was logged in on a server, by ssh, with a vim open, when the battery of my laptop got empty. When I return to the server by ssh, I can see my previous ssh session still open, and the vim process running (ttyp0). Is there a way to attach that vim to my new session (ttyp4)? Here's part... (2 Replies)
Discussion started by: raphinou
2 Replies

5. Programming

Need the PID of a process in a thread

How do I run a process from a C++ p_thread and obtain its PID? Right now I am doing in a p_thread: system("ampl method.run"); and into the main function (after running the thread mentioned before): sleep(5); //Just to be sure that the thread is executing the ampl command system("ps... (1 Reply)
Discussion started by: riccollado
1 Replies

6. UNIX for Dummies Questions & Answers

process and thread

i want to know a difference between process and thread,give a program to tell the difference (2 Replies)
Discussion started by: annapurna konga
2 Replies

7. UNIX for Dummies Questions & Answers

Thread count for a process id

Hi, I want to know a command/program to get thread count for a process id in unix box. Please help me in this regard. (1 Reply)
Discussion started by: manaac
1 Replies

8. Programming

dbx - attach to process, break when crash

Hey everyone, I have a process that is crashing, and I'd like to have some way to see where it crashes. Is this possible? (2 Replies)
Discussion started by: ctote
2 Replies

9. Shell Programming and Scripting

Get the process/thread running on which core

I use top -H -p 1256 to show process 1256, and then press "f" then press "j" to display it is running on which core, is there a better mothed, I want to be automated to get this (1 Reply)
Discussion started by: yanglei_fage
1 Replies

10. UNIX for Beginners Questions & Answers

Attach process with port 2222

Hi Team, is there any way, I can start any process for e.g. run a shell script (infinite loop) and attach it to port 2222? I am trying to create a scenario where an application will start running at port 2222 and I will telnet the same to confirm, application port is listening. So,... (1 Reply)
Discussion started by: vivekpandit7
1 Replies
GRANTPT(3)						   BSD Library Functions Manual 						GRANTPT(3)

NAME
grantpt, posix_openpt, ptsname, ptsname_r, unlockpt -- pseudo-terminal access functions SYNOPSIS
#include <stdlib.h> int grantpt(int fildes); char * ptsname(int fildes); int ptsname_r(int fildes, char *buffer, size_t buflen); int unlockpt(int fildes); #include <stdlib.h> #include <fcntl.h> int posix_openpt(int oflag); DESCRIPTION
The grantpt(), ptsname(), ptsname_r(), unlockpt(), and posix_openpt() functions allow access to pseudo-terminal devices. The first four functions accept a file descriptor that references the master half of a pseudo-terminal pair. This file descriptor is created with posix_openpt(). The grantpt() function is used to establish ownership and permissions of the slave device counterpart to the master device specified with fildes. The slave device's ownership is set to the real user ID of the calling process; its permissions are set to user readable-writable and group writable. The group owner of the slave device is also set to the group ``tty'' if it exists on the system; otherwise, it is left untouched. The ptsname() and ptsname_r() functions return the full pathname of the slave device counterpart to the master device specified with fildes. This value can be used to subsequently open the appropriate slave after posix_openpt() and grantpt() have been called. The ptsname() function is not guaranteed to be reentrant or thread safe. The ptsname_r() function takes a buffer and length as arguments to avoid this problem. The unlockpt() function unlocks the slave pseudo-terminal device associated with the master device to which fildes refers. The posix_openpt() function opens the first available master pseudo-terminal device and returns a descriptor to it. The oflag argument spec- ifies the flags used for opening the device: O_RDWR Open for reading and writing. O_NOCTTY If set, do not allow the terminal to become the controlling terminal for the calling process. RETURN VALUES
The grantpt() and unlockpt() functions return the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. The ptsname() function returns a pointer to the name of the slave device on success; otherwise a NULL pointer is returned and the global variable errno is set to indicate the error. The ptsname_r() function returns 0 if successful. On failure, it returns -1 and the global variable errno is set to indicate the error. The posix_openpt() function returns a file descriptor to the first available master pseudo-terminal device on success; otherwise -1 is returned and the global variable errno is set to indicate the error. ERRORS
The grantpt(), ptsname(), ptsname_r(), and unlockpt() functions may fail and set errno to: [EINVAL] fildes is not a master pseudo-terminal device. In addition, the ptsname_r() function may set errno to: [EINVAL] The buffer argument is NULL. [ERANGE] The bufsize argument is smaller than the length of the string to be returned. In addition, the grantpt() function may set errno to: [EACCES] The slave pseudo-terminal device could not be accessed. The posix_openpt() function may fail and set errno to: [EINVAL] oflag consists of an invalid mode bit. [EAGAIN] The system has no available pseudo-terminal devices. The grantpt(), ptsname(), ptsname_r(), and unlockpt() functions may also fail and set errno for any of the errors specified for the fstat(2) system call. The posix_openpt() function may also fail and set errno for any of the errors specified for the open(2) system call. LEGACY SYNOPSIS
#include <stdlib.h> #include <fcntl.h> int grantpt(int fildes); char * ptsname(int fildes); int unlockpt(int fildes); #include <fcntl.h> int posix_openpt(int oflag); SEE ALSO
open(2), pty(4), tty(4), compat(5) STANDARDS
The grantpt(), ptsname(), unlockpt(), and posix_openpt() functions conform to IEEE Std 1003.1-2001 (``POSIX.1''). BSD
February 2, 2005 BSD
All times are GMT -4. The time now is 04:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy