Professional Web Applications Themes

replacing a binary while operational - UNIX Programming

Hi, I am trying to scp a binary from one machine to another machine nad it gives me the error message: scp:/bin/my_prog: text file busy The program my_prog is actually running on the machine to which i am trying to copy. Unix allows replacing the binaries on the fly and why does this error come up and what should i do to prevent this. Also, my_prog is a program written by me and is more like a daemon process. thanks Karthik...

  1. #1

    Default replacing a binary while operational

    Hi,

    I am trying to scp a binary from one machine to another machine nad it
    gives me the error message:

    scp:/bin/my_prog: text file busy

    The program my_prog is actually running on the machine to which i am
    trying to copy. Unix allows replacing the binaries on the fly and why
    does this error come up and what should i do to prevent this. Also,
    my_prog is a program written by me and is more like a daemon process.

    thanks

    Karthik

    Karthik Guest

  2. #2

    Default Re: replacing a binary while operational


    "Karthik" <com> wrote in message
    news:c1e1nq$1k2$wright.edu... 


    Because the running program needs continuous access to the unmodified
    file. UNIX machines don't actually load a file into memory in order to run
    it, they just map it into memory and allow it to load in as needed. As a
    result, the file cannot be modified while it's being executed.

     


    Yes, UNIX does allow *replacing* binaries on the fly, but you're not
    trying to replace it, you're trying to modify it. The easiest solution is
    probably to 'rm' the file before trying to upload. This will prevent you
    from attempting to modify it.

    DS



    David Guest

  3. #3

    Default Re: replacing a binary while operational

    In article <c1e2bi$n2v$webmaster.com>,
    "David Schwartz" <com> wrote:
     
    >
    >
    > Yes, UNIX does allow *replacing* binaries on the fly, but you're not
    > trying to replace it, you're trying to modify it. The easiest solution is
    > probably to 'rm' the file before trying to upload. This will prevent you
    > from attempting to modify it.[/ref]

    And some versions of Unix don't even report the "Text file busy" error,
    they simply let you overwrite a program that's in use. The usual result
    of this is that the process running the program crashes or gets
    erroneous results, because the positions of instructions or data are
    different in the new version of the program than the one it started up.

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Guest

  4. #4

    Default Re: replacing a binary while operational

    > And some versions of Unix don't even report the "Text file busy" error, 

    Which "always" happens for sh-scripts (which are just being read rather than
    being executed as far as the kernel knows).


    Stefan
    Stefan Guest

  5. #5

    Default Re: replacing a binary while operational

    >>> Karthik wrote:

    K> I am trying to scp a binary from one machine to another machine nad it
    K> gives me the error message:
    K>
    K> scp:/bin/my_prog: text file busy
    K>
    K> The program my_prog is actually running on the machine to which i am
    K> trying to copy. Unix allows replacing the binaries on the fly and why
    K> does this error come up and what should i do to prevent this. Also,
    K> my_prog is a program written by me and is more like a daemon process.

    Place it in the same directory with another name and then apply
    atomic rename.


    -netch-
    Valentin Guest

  6. #6

    Default undefined reference error

    Hi everyone,

    Thanks for all the suggestions on my previous post regarding replacing
    binaries during execution.

    I am getting a few undefined reference errors during compilation. The
    error message is:

    ------
    /root/tmp/cc5h04lE.o(.text+0x11ee): In function `main':
    /root/init_test/init/main.cpp:596: undefined reference to
    `init_auth_itself()'
    /root/tmp/cc5h04lE.o(.text+0x11f9):/root/init_test/init/main.cpp:597:
    undefined reference to `kernel_auth()'
    collect2: ld returned 1 exit status
    ------

    ------
    # nm *.o | grep auth
    00000048 T init_auth_itself
    0000003e T kernel_auth
    U authunix_create_default
    #
    ------

    The two functions are implemented in a different file and I have
    included the object file for linking. Is there any limitation in the
    number of object files that can be passed for linking purposes. I have
    around 20 - 30 object files as input for linking the main binary.

    Any suggestions would be really helpful

    Karthik

    Karthik Guest

  7. #7

    Default Re: undefined reference error



    Karthik wrote:
     

    20-30 should not pose a problem for any linker.
    It may be the order of references.

    See man pagers for lorder(1) and tsort(1)



    --

    "It is impossible to make anything foolproof because fools are so
    ingenious" - A. Bloch

    Nick Guest

  8. #8

    Default Re: undefined reference error

    Karthik <com> writes:
     

    You don't. You get an error message during *linking*
     

    The 'nm' output you've posted indicates that the missing functions
    have 'extern "C"' linkage. Unresolved references come from C++ code.

    Do the "problem" functions have 'extern "C"' when they are prototyped
    in main.cpp ? Probably not ...
     

    There is a limitation on total command-line length. If you exceed
    that limit, make or your shell will fail with 'argument list too
    long'.

    You did not specify what system you've done this on, but it looks
    like Linux, where the command-line-limit is almost 32 pages
    (128KBytes) long. We can safely assume you did not hit that limit.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.
    Paul Guest

  9. #9

    Default Re: undefined reference error



    The problem was not including both the functions inside the extern "C"
    linkage. I had 12 other functions which i had in there but forogt to
    include these functions within the linkage structure. [should'nt work
    late in the nights !]

    It was interesting to note how you determined form the output of nm that
    these functions require extern "C" linkage. !! i read the man page and
    could'nt find any references of how to determine those. Can you give me
    some insight on this ?

    Thanks

    Karthik

    Karthik Guest

  10. #10

    Default Re: undefined reference error

    Karthik <com> writes:
     

    The way C++ (usually) implements function overloading is via
    name-mangling, that is by encoding parameter types into the
    function name.

    Thus, when you compile

    void foo(void) {}
    void foo(int) {}
    void foo(long) {}

    the nm output looks like this (g++-2.9x):
    0000000c T foo__Fi
    00000018 T foo__Fl
    00000000 T foo__Fv

    or like this (g++-3.x):
    00000006 T _Z3fooi
    0000000c T _Z3fool
    00000000 T _Z3foov

    Other C++ compilers use similar schemes. Your symbols were not so
    adorned, which led me to the conclusion that they have "C" linkage.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.
    Paul Guest

Similar Threads

  1. The server is not operational
    By CalSun in forum ASP.NET Security
    Replies: 21
    Last Post: January 23rd, 10:59 PM
  2. System.DirectoryServices - The server is not operational
    By George Durzi in forum ASP.NET Security
    Replies: 10
    Last Post: December 29th, 12:00 AM
  3. Replies: 5
    Last Post: June 26th, 12:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139