unix questions. need help!

Discussion in 'OT Technology' started by hurleyint1386, Nov 1, 2005.

  1. hurleyint1386

    hurleyint1386 Someone has sand in their vagina

    Joined:
    Jan 6, 2005
    Messages:
    3,687
    Likes Received:
    0
    Location:
    Rochester, NY
    ok, i have 2 questions:
    what's the difference between execv () and execvp ()?
    also, what happens when a writer tries to overflow a pipe?
     
  2. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
  3. hurleyint1386

    hurleyint1386 Someone has sand in their vagina

    Joined:
    Jan 6, 2005
    Messages:
    3,687
    Likes Received:
    0
    Location:
    Rochester, NY
    the second one was a homework question because i cant find the answer to it. i've tried googling it, but cant find anything. the first one i just didnt know because in my unix book it has the exact same definition:
    int execv(const char* path, const char* argv[])
    and
    int execvp(const char* path, const char* argv[])
     
  4. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    why not read the documentation on execv/p. leme guess 1st year comp sci class.

    the answer to the 2nd question is also on google, refine your search. it was my 2nd hit out of 33.
     
  5. hurleyint1386

    hurleyint1386 Someone has sand in their vagina

    Joined:
    Jan 6, 2005
    Messages:
    3,687
    Likes Received:
    0
    Location:
    Rochester, NY
    actually second year, but still cant find it. i also looked at the documentation on it and im not seeing anything in the "Unix for Progammers and Users" by Glass and Ables
     
  6. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    For a 2nd year compter science student you should be able to read man pages. Both of these functions are described in detail there.

    As for your second question, why not write a program using the aforementioned exec family of system calls and try to write to a socket that has been closed to see what happens?
     
  7. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    10
    Location:
    Los Angeles
    Many schools utilize different methods of teaching and construct their classes differently than others. Not everybody had the same order of classes as you did.

    For the record, I didn't take a Unix class until my 4th semester.
     
  8. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    Reading man pages is basic stuff. If it is not taught during your C programming course your first or second semester, you should take 10 minutes and teach yourself.
     
  9. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    man pages + grep = cutting all the fat out and getting to the meat.

    For a 2nd year student, you have to become more resourceful. Come 3rd and 4th year, if you are unable to do a quick google search of "execv() vs execvp()" you're gonna get your ass handed to you, and should probably quit now saving your time & money.

    Hell the textbooks I use now are just for reference and are not hardly used. Most of my classes are lectures/hands on with a TON of research. Why? If you are unable to produce a quality report/idea/thesis in the educational enviroment; come up with your own thesis and find research to support it; or even think outside the box; you will get eaten alive in the work enviroment. Businesses want innovaters, people who can save them or make them money.
     
  10. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Second year here as well.

    However, how to use a man page is like the first thing they teach.
     
  11. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    10
    Location:
    Los Angeles
    You missed the point.

    It may not be so "basic" to someone completely new to Unix. They may not even know that the 'man' command exists. How could they educate themselves on something they don't know exists? Furthermore, I'm sure he's willing to spend that extra time learning things that are in his current curriculum, such as studying more cryptic C challenges if he's taking a C programming class.

    That being said, give the newbie a break. We all start somewhere.
     
  12. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    10
    Location:
    Los Angeles
    Well, good for you. Your professor knew what to teach first. Unfortunately, there are a lot of professors who do not teach people how to do that immediatly, and there are even a lot of professors who no longer care, they just teach simply because they can't get fired because they've been with the same University for 10+ years.

    Being the ignorant individuals that we are, his professor may end up teaching the students how to use the man command at the end of the course.

    Edit:
    My unix professor was a fucking moron. All unix I know is self taught.
     
  13. col_panic

    col_panic calm like a bomb Moderator

    Joined:
    Sep 19, 2003
    Messages:
    188,160
    Likes Received:
    0
    Location:
    winter haven, fl
    qft

    you need to learn how to find answers yourself

    groups.google.com ftw
     
  14. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,216
    Likes Received:
    521
    man 3 execvp
     
  15. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,216
    Likes Received:
    521
    execv(3) - Linux man page
    NAME
    execl, execlp, execle, execv, execvp - execute a file
    SYNOPSIS
    #include <unistd.h>

    extern char **environ;

    int execl(const char *path, const char *arg, ...); int execlp(const char *file, const char *arg, ...); int execle(const char *path, const char *arg , ..., char * const envp[]); int execv(const char *path, char *const argv[]); int execvp(const char *file, char *const argv[]);
    DESCRIPTION
    The exec family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for the function execve(2). (See the manual page for execve for detailed information about the replacement of the current process.)

    The initial argument for these functions is the pathname of a file which is to be executed.

    The const char *arg and subsequent ellipses in the execl, execlp, and execle functions can be thought of as arg0, arg1, ..., argn. Together they describe a list of one or more pointers to null-terminated strings that represent the argument list available to the executed program. The first argument, by convention, should point to the file name associated with the file being executed. The list of arguments must be terminated by a NULL pointer.

    The execv and execvp functions provide an array of pointers to null-terminated strings that represent the argument list available to the new program. The first argument, by convention, should point to the file name associated with the file being executed. The array of pointers must be terminated by a NULL pointer.

    The execle function also specifies the environment of the executed process by following the NULL pointer that terminates the list of arguments in the parameter list or the pointer to the argv array with an additional parameter. This additional parameter is an array of pointers to null-terminated strings and must be terminated by a NULL pointer. The other functions take the environment for the new process image from the external variable environ in the current process.

    Some of these functions have special semantics.

    The functions execlp and execvp will duplicate the actions of the shell in searching for an executable file if the specified file name does not contain a slash (/) character. The search path is the path specified in the environment by the PATH variable. If this variable isn't specified, the default path ``:/bin:/usr/bin'' is used. In addition, certain errors are treated specially.

    If permission is denied for a file (the attempted execve returned EACCES), these functions will continue searching the rest of the search path. If no other file is found, however, they will return with the global variable errno set to EACCES.

    If the header of a file isn't recognized (the attempted execve returned ENOEXEC), these functions will execute the shell with the path of the file as its first argument. (If this attempt fails, no further searching is done.)
    RETURN VALUE
    If any of the exec functions returns, an error will have occurred. The return value is -1, and the global variable errno will be set to indicate the error.
    FILES
    /bin/sh
    ERRORS
    All of these functions may fail and set errno for any of the errors specified for the library function execve(2).
    SEE ALSO
    sh(1), execve(2), fork(2), environ(5), ptrace(2)
    COMPATIBILITY
    On some other systems the default path (used when the environment does not contain the variable PATH) has the current working directory listed after /bin and /usr/bin, as an anti-Trojan-horse measure. Linux uses here the traditional "current directory first" default path.

    The behavior of execlp and execvp when errors occur while attempting to execute the file is historic practice, but has not traditionally been documented and is not specified by the POSIX standard. BSD (and possibly other systems) do an automatic sleep and retry if ETXTBSY is encountered. Linux treats it as a hard error and returns immediately.

    Traditionally, the functions execlp and execvp ignored all errors except for the ones described above and ENOMEM and E2BIG, upon which they returned. They now return if any error other than the ones described above occurs.
    CONFORMING TO
    execl, execv, execle, execlp and execvp conform to IEEE Std1003.1-88 (``POSIX.1'').
    REFERENCED BY
    xltcheckargsize(3)
     

Share This Page