smintz ,
1) programs that explicitly make use of "/dev/tty" are editors (like vi) or other apps that use libcurses ; Any other apps - ordinarilly - should write to stdout and/or stderr , and read from stdin , thus honoring the Unix programming paradigm as set forth by ken thompson since `the epoch'
-- if you don't recognize some of the info above , it'll be illustrative for you in your journey getting to know Unix better ... so not to worry about it now ;
The point here is that all programmers that stick to the model , can make use of all the power that Unix provides , without any undesired side effects ;
Explicitly , any program that works as below :
$ prog < input.dat > prog.out 2> prog.err
can be used without worries with all the rest of unix ;
but remember : programs that instead use "/dev/tty" as input and output ,
cannot make use of these facilities ;
** now let's get to nohup ... shall we ?
2) nohup was invented in order to keep a program running even if the user that started it has logged out ... otherwise the program would receive a NOHUP signal upon the user's logoff ;
that said , when a user runs :
$ nohup prog &
he/she can harmlessly logout and rest assured that his/her program would keep running after logoff ;
obviously if the program has anything to tell , who would be there to hear , if the user bailed out ?
this is taken care of by means of the 'nohup.out' file (provided automatically by nohup) ;
the point here is : "any program subjet to nohup MUST adhere to the Unix I/O programing model" , that is , it's i/o MUST be "redirectable" as shown above ;
this is why nohup can't handle "/dev/tty" communication ;
and this is why a "good use" of nohup includes redirecting all i/o ;
** now explicitly - if you use it like :
$ nohup prog < input.dat > prog.out 2> prog.err &
than everything works fine ... provided that "prog" is a well-behaved application ;
*** now , with regard to shell scripts , just bear in mind that the shell itself is a programm , and "your application" (whatever it may be) is another application, and whoever goes into background MUST redirect its I/O , ok ?
just one last thing ... using ">" and "1>" has the same effect , so
$ prog > fileA 1> fileB
has no meaning ... you will not have a duplicated output ;
-- hope this starts your clarification on the subjects ;
good luck , and success !
alexandre botao ( Alexandre V. R. Botao | Unix, C/C++, Shell, LDAP, SSL/TLS, SSH, Perl, Java, Python, Security, ... )