小编hau*_*d85的帖子

如何触发SIGUSR1和SIGUSR2?

我已经熟悉了C中的信号.我无法弄清楚是什么类型的信号SIGUSR1,SIGUSR2我怎么能触发它们.有人可以向我解释一下吗?

c signals

51
推荐指数
3
解决办法
12万
查看次数

jQuery动画和属性值百分比

我试图动画一个div,我试图在其他地方使用一些值进行检索,我知道这个值是正确的,因为我打印出输出...所以我想知道为什么它不能正常工作?

animateBar(percentage.toFixed(2)+'%');

[ . . . ]

function animateBar(percentage)
{
    $('#innerBox').animate({width: percentage}, 3000);
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-animate

12
推荐指数
3
解决办法
2万
查看次数

gcc 和缓存

我正在开发一个 C 程序,奇怪的是当我更新源文件时,我没有看到生成的可执行文件有任何变化。gcc 是否有可能存储文件的缓存副本,即使我编译我也没有获得更新版本的可执行文件?在这种情况下,如何强制编译器使用新编辑的文件?

我正在使用以下内容编译我的代码:

# gcc -o myExecFileName source_file_1.c source_file2.c
Run Code Online (Sandbox Code Playgroud)

c compiler-construction caching

5
推荐指数
1
解决办法
5825
查看次数

文件通配和仅匹配数字

在bash脚本中,我需要验证用户输入的实际数字,所以我认为最简单的方法是让自己确定这是实现一个case:

case $1 in
    [0-9]*)
    echo "It's ok"
    ;;
    *)
    echo "Ain't good!"
    exit 1
    ;;
esac 
Run Code Online (Sandbox Code Playgroud)

但我很难用文件通配,因为我找不到一种方法来要求$ 1值必须只是数字.或者另一种方式可以排除所有替代方案:

case $1 in
    -*)
    echo "Can't be negative"
    exit 1
    ;;
    +*)
    echo "Must be unsigned"
    exit 1
    ;;
    *[a-zA-z]*)
    echo "Can't contain letters"
    exit 1
    ;;
esac
Run Code Online (Sandbox Code Playgroud)

事情是在这种情况下,我应该能够阻止"特殊"字符!?^ =()等等......我不知道如何实现它.请有人给我一个提示吗?

bash design-patterns glob

3
推荐指数
2
解决办法
4884
查看次数

终止线程后返回值错误

我接近在C并行线程和我开始写作非常愚蠢的程序,让他们的窍门.我试图创建一个包含两个线程的程序,他们应该打印他们的名字,并在终止执行时收集他们的状态.所以我的代码是:

//Function declaration
void *state_your_name(char*);

//Function definition

//Passing a string as parameter for 
//outputting the name of the thread
void *state_your_name(char *name) {
    //Declaration of the variable containing the return status
    void* status;

    //Printing out the string
    printf("%s\n", name);
    //Exiting the thread and saving the return value
    pthread_exit(status);
}

int main(void) {
    pthread_t tid_1, tid_2;
    void * status;

    //Creating thread 1...
    if (pthread_create(&tid_1, NULL, state_your_name, "Thread 1")) {
        printf("Error creating thread 1");
        exit(1);
    }

    //Creating thread 2...    
    if (pthread_create(&tid_2, NULL, …
Run Code Online (Sandbox Code Playgroud)

c pthreads return-value

3
推荐指数
1
解决办法
430
查看次数

Javascript:获取节点值

我对Javascript很陌生,我需要获取具有id的节点的值,firstvalue以便可以在脚本中使用它。谁能告诉我我如何获得这一价值?

<div id="myDiv">

<span id="firstValue"> 5.22 <span id="nestedValue"> 500 </span></span>

</div> <!-- myDiv -->
Run Code Online (Sandbox Code Playgroud)

javascript

2
推荐指数
1
解决办法
8142
查看次数

jQuery无法将onmousedown应用于锚标签

我有这样的导航菜单

<ul id="nav">
<li> <a id="firstLink" href="#"> Link 1 </a> </li>
<li> <a id="secondLink" href="#"> Link 2 </a> </li>
<li> <a id="thirdLink" href="#"> Link 3 </a> </li>
<li> <a id="fourthLink" href="#"> Link 4 </a> </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我想在鼠标停止时将一个函数关联到每个锚标签,所以我有一个外部的js文件,而我的代码是

$(document).ready(function() {
$('#firstLink').onmousedown(doSomething());
[ ... ]
});

function doSomething() {
// this function does something
}
Run Code Online (Sandbox Code Playgroud)

我的问题是如果我把事件处理程序内联,脚本工作,没有问题.

<li> <a href="#" id="firstLink" onmousedown="doSomething()"> Link 1 </a> </li>
Run Code Online (Sandbox Code Playgroud)

另一方面,如果我使用外部文件,如上所示,没有任何反应,Chrome会让我回来Uncaught TypeError: Object [object Object] has no method onmousedown,Firefox和Firebug会回复我$("#firstLink").onmousedown is not a function.我不明白,我做错了什么?

javascript anchor jquery onmousedown

2
推荐指数
1
解决办法
2366
查看次数

jQuery和链接问题

我是一个jQuery新手,也许我想问一个非常基本的问题,但我真的很挣扎,同时弄清楚为什么jQuery链在我的情况下不起作用.

var container = $('#container'),
items = container.find('ul.items'),
moreItems = items.children('li.moreItems');

var config = {
container : container,
items : items,
moreItems : moreItems
}

var app = myApp(config);

function MyApp(config) {
this.container = config.container;
this.items = config.items;
this.moreItems = config.moreItems;
this.current = 0;
}

MyApp.prototype.myUsefulFunction() {
this.moreItems[this.current].fadeIn();
}
Run Code Online (Sandbox Code Playgroud)

假设我有一个div#container,其中包含每个都有多个li的ul元素.我想访问第n个li并淡化元素,但是控制台抛出了一个错误,说明fadeIn没有这样的方法.你能帮我解决一下吗?

jquery chain

2
推荐指数
1
解决办法
251
查看次数

分叉后父母永远不会执行

我正在尝试熟悉管道,我写了一个非常愚蠢的鹦鹉程序,基本上从键盘输入,然后显示完全相同的事情:

if (pipe(fd) < 0) {
        perror("Pipe");
        exit(1);
    }

    if ( ( pid = fork() < 0 ) ) {
        perror("Fork");
        exit(1);
    }

    if ( pid > 0 ) //If I'm the parent...
    {
        printf("Parent!");
        close(fd[0]);
        //as long as something is typed in and that something isn't 
        // the word "stop"
        while (((n = read(STDIN_FILENO, buffer, BUFFERSIZE)) > 0) && 
               (strncmp(buffer, "stop", 4) != 0))
        {
            //shove all the buffer content into the pipe
            write(fd[1], buffer, BUFFERSIZE);
        }
    }
    else …
Run Code Online (Sandbox Code Playgroud)

c fork

1
推荐指数
1
解决办法
70
查看次数

Oracle:异常和错误

我已经在SQL中编写了这个函数,我无法弄清楚为什么,但它继续在异常部分返回错误.我检查了语法,记录了但我没有运气,有人请帮忙吗?


错误返回:

Error on line 83: PLS-00103: Found symbol "EXCEPTION" instead one of the following:
    begin case declare end exit for goto if loop mod null pragma raise return select update while with
    <<
    close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe
Run Code Online (Sandbox Code Playgroud)
create or replace function InsertPeriodoEvento
    (NomePeriodo in varchar,
    aInizio in integer,
    aFine in integer,
    NomeEvento1 in varchar,
    g1 in integer,
    m1 in integer,
    a1 in integer,
    NomeEvento2 in varchar,
    g2 …
Run Code Online (Sandbox Code Playgroud)

oracle plsql exception-handling pls-00103

0
推荐指数
2
解决办法
340
查看次数