Run a subprocess in a pseudo terminal


#1

I am trying to build a small script which would initiate workers on PBS cluster through interactive job. For that I need a way to execute cat $PBS_NODEFILE in interactive session to get associated resources to me. Essentially what I would like to accomplish is something like this:

output, input, p = readandwrite(`qsub -I`)
readline(output) # waiting for job to start
write(input,"cat \$PBS_NODEFILE \n")
# Reading given resources

# Starting julia workers with my custom needs

# Doing some calculation

# Killing interactive session and so the job
kill(p,9)

But I get an error after executing readandwrite(qsub -I):

qsub:    standard input and output must be a terminal for                                                                                           interactive job submission

How could I get around that?

EDIT

I am looking for similar behavior what ptyprocess offers.


#2

See https://github.com/JuliaParallel/ClusterManagers.jl for PBS support.

(Note that it uses some command-line options to qsub to run it in batch mode. Hopefully you won’t need to run qsub directly and can use ClusterManagers instead.)


#3

ClusterManagers works fine and I have been using it extensively . However it does not allow to specify how workers should be initiated. For example, I would like to have a one worker per node for making BLAS faster with threading.


#4

Janis, I manage a PBS cluster. I think that the qsub behaviour for interactive jobs is correct. I think you understand that also.
I will log in and see if we can make a construct which behaves like ptyprocess though.


#5

Thanks. However I have changed my mind on how I could approach this problem, I found that I can actually establish ssh connection with main node when I run submitted job. Some ideas are running in my mind how to use that.

But perhaps the simplest solution is to submit a job which creates a machinefile and exits when that file is deleted.