Frequently Asked Questions about Unix - with Answers

mike at bria mike at bria
Thu Feb 7 10:11:28 AEST 1991


In an article, drake.almaden.ibm.com!drake writes:
>You know, it's things like this that let some folks believe UNIX is
>cryptic and difficult to use.  Let's summarize the FAQs:

Come on now, some of this is hogwash ...

>	8)  How do I find the name of an open file?

Determine the process that has the file open, get the inode from /dev/kmem
and read /dev/rhd? (or whatever) for the name.

>	14) How do I {set an environment variable, change directory} inside a
>	      program or shell script and have that change affect my
>	      current shell?

For a program, you build a token table, copying from _environ, and use
that instead of getenv() and putenv(); for shell scripts, you run the
script in the instance of your current shell using the dot.

>	21) How do I "undelete" a file?

This is a tough one, but there is a program (appropriately called ButtSaver)
that will do an undelete on a file (and not using the wimpy Norton rename
kludge.)

>	22) How can a process detect if it's running in the background?

Read the process table out of /dev/kmem and have the process examine
it's pedigree in relationship to other processes in the same pgroup.

>	23) How can an executing program determine its own pathname?

You _may_ not be able to.  How about looking in argv[0] and resolving the
path?  It won't work in every instance, but then again, it's better than
nothing.

>	28) How do I sleep() in a C program for less than one second?

Use nap() instead.
-- 
Michael Stefanik                       | Opinions stated are not even my own.
Systems Engineer, Briareus Corporation | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly
found to be saying things like "Well, it works on my DOS machine ..."



More information about the Comp.unix.questions mailing list